Beispiel #1
0
void menuDeleteFlight(char* passMsg) {
	Flight flight = { NULL, NULL, 0, 0 };

	programHeader();
	printf("Usuwanie lotu:\n\n");

	if (_inputFlight(&flight)) {
		if (flight.from == NULL) {
			sprintf(passMsg, "Nie mozna usunac lotu. Lotnisko wylotu nie istnieje w bazie.\n");
		}
		if (flight.to == NULL) {
			sprintf(passMsg, "Nie mozna usunac lotu. Lotnisko przylotu nie istnieje w bazie.\n");
		}
		else {
			Flight* ref = findFlightByAllData(DB_HANDLE,
				flight.from, flight.to, flight.departure, flight.duration);
			if (ref == NULL) {
				sprintf(passMsg, "Nie mozna usunac lotu. Lot z (%s, %s) do (%s, %s) o %hu:%02hu nie istnieje.\n",
					flight.from->name, flight.from->country, flight.to->name, flight.to->country,
					getHour(&flight.departure), getMinutes(&flight.departure));
			}
			else {
				removeFlight(DB_HANDLE, ref);
				sprintf(passMsg, "Lot z (%s, %s) do (%s, %s) o %hu:%02hu zostal usuniety.\n",
					flight.from->name, flight.from->country, flight.to->name, flight.to->country,
					getHour(&flight.departure), getMinutes(&flight.departure));
			}
		}
	}
	else {
		sprintf(passMsg, "Nie mozna usunac lotu. Niepoprawne/niepelne dane.\n");
	}

	menuPrintAllFlights(passMsg);
}
//Arma una URL para Google Maps con la ubicación actual leída por el GPS (CREDITO POR DESCIFRAR EL URL DE DANIEL ROJAS :D)
void GPS_5Hz::printURL()
{
    Serial.print("https://www.google.com/maps/preview#!q=");
    Serial.print(getDegrees(LATITUDE));
    Serial.print("%C2%B0+");
    Serial.print(getMinutes(LATITUDE), 4);
    Serial.print("'%2C+-");
    Serial.print(getDegrees(LONGITUDE));
    Serial.print("%C2%B0+");
    Serial.print(getMinutes(LONGITUDE), 4);
    Serial.println("'");
}
void vrpProblem::load(const char* filename) {
  easer();  
  ifstream file(filename);
  cout << ">> Loading [" << filename << "]" << endl;
  double buffer;
  if (file) 
  {  
      file >> _num_stops;         //read the number of stops
      file >> _capacity_veh;      //read the capacity of vehicle
      file >> _speed;             //speed of vehicle     
      file >> _max_total_dist;    //get maximum total dist of a vehicle   
      _list_stops = new vrpStop[_num_stops];

      //read all property of stops    
      for (unsigned int i = 0; i < _num_stops; i++) {	
          file >> buffer;
          _list_stops[i].ID = (unsigned int)buffer;
          file >> buffer;
          _list_stops[i].X = buffer;
          file >> buffer;
          _list_stops[i].Y = buffer;
          file >> buffer;
          _list_stops[i].EarlyTime = getMinutes(buffer); 
          file >> buffer;
          _list_stops[i].LateTime = getMinutes(buffer); 
          file >> buffer;
          _list_stops[i].ServiceTime = buffer/60; 
          file >> buffer;
          _list_stops[i].Load = buffer;
          file >> buffer;
          _list_stops[i].Type = (unsigned int)buffer;	    
      }	    
      //get information about conflict stops
      unsigned int count_group;    
      file >> count_group; //number of the group customer
      for(unsigned int i = 0 ; i < _num_stops ; i++) {
          if(_list_stops[i].Type != REGULAR_STOP)        
              _list_stops[i].Group = NON_GROUP;        
          else        
              _list_stops[i].Group = _list_stops[i].ID % count_group;        
      }
      _conflict_group = new vrpGroupConflict(count_group);
      unsigned int group_A, group_B;
      while(file >> group_A >> group_B )    
          _conflict_group->pushConflictGroup(group_A, group_B); 
      file.close();
      computeDistances();    
  }
  else 
  {
Beispiel #4
0
Period *Period::normalizedStandard(const PeriodType *type) {
    type = DateTimeUtils::getPeriodType(type);
    int64_t millis = getMillis();  // no overflow can happen, even with Integer.MAX_VALUEs
    millis += (((int64_t) getSeconds()) * ((int64_t) DateTimeConstants::MILLIS_PER_SECOND));
    millis += (((int64_t) getMinutes()) * ((int64_t) DateTimeConstants::MILLIS_PER_MINUTE));
    millis += (((int64_t) getHours()) * ((int64_t) DateTimeConstants::MILLIS_PER_HOUR));
    millis += (((int64_t) getDays()) * ((int64_t) DateTimeConstants::MILLIS_PER_DAY));
    millis += (((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::MILLIS_PER_WEEK));
    Period *result = new Period(millis, type, ISOChronology::getInstanceUTC());
    int years = getYears();
    int months = getMonths();
    if (years != 0 || months != 0) {
        int64_t totalMonths = years * 12L + months;
        if (type->isSupported(DurationFieldType::YEARS_TYPE)) {
            int normalizedYears = FieldUtils::safeToInt(totalMonths / 12);
            result = result->withYears(normalizedYears);
            totalMonths = totalMonths - (normalizedYears * 12);
        }
        if (type->isSupported(DurationFieldType::MONTHS_TYPE)) {
            int normalizedMonths = FieldUtils::safeToInt(totalMonths);
            result = result->withMonths(normalizedMonths);
            totalMonths = totalMonths - normalizedMonths;
        }
        if (totalMonths != 0) {
            string err("Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: ");
            err.append(toString());
            throw UnsupportedOperationException(err);
        }
    }
    return result;
}
Beispiel #5
0
 std::string as_string()const
 {
     const int MAX_TIMESTING_LEN = 256;
     char repr[MAX_TIMESTING_LEN];
     sprintf(repr, "%3s:%02d:%02d", getDayString().c_str(), getHours(), getMinutes());
     return std::string(repr);
 }
Beispiel #6
0
std::string CCopasiTimeVariable::isoFormat() const
  {
    std::stringstream Iso;
    bool first = true;

    if (mTime < LLONG_CONST(0))
      {
        CCopasiTimeVariable Tmp(-mTime);
        Iso << "-";
        Iso << Tmp.isoFormat();

        return Iso.str();
      }

    if (mTime >= LLONG_CONST(86400000000))
      {
        Iso << LL2String(getDays()) << ":";
        first = false;
      }

    if (mTime >= LLONG_CONST(3600000000))
      Iso << LL2String(getHours(true), first ? 0 : 2) << ":";
    if (mTime >= LLONG_CONST(60000000))
      Iso << LL2String(getMinutes(true), first ? 0 : 2) << ":";
    if (mTime >= LLONG_CONST(1000000))
      Iso << LL2String(getSeconds(true), first ? 0 : 2) << ".";
    else
      Iso << "0.";

    Iso << LL2String(getMilliSeconds(true), 3) << LL2String(getMicroSeconds(true), 3);

    return Iso.str();
  }
Beispiel #7
0
int Date::test()
{
	unsigned long long gg = getDays(2008,12,31);
	getDateFromDays(gg);
	gg = getHours(2008,12,31,12);
	getDateFromHours(gg);
	gg = getMinutes(2008,12,31,12,56);
	getDateFromMinutes(gg);
	gg = getSeconds(2008,12,31,12,56,56);
	getDateFromSeconds(gg);
	Date d;
	//logger << d.toString() << endl;
	Date d1 = addYearsGet(1);
	//logger << d1.toString() << endl;
	Date d2 = addMonthsGet(23);
	//logger << d2.toString() << endl;
	Date d3 = addDaysGet(17);
	//logger << d3.toString() << endl;
	Date d4 = addHoursGet(25);
	//logger << d4.toString() << endl;
	Date d5 = addMinutesGet(61);
	//logger << d5.toString() << endl;
	Date d6 = addSecondsGet(61);
	//logger << d6.toString() << endl;
	return 0;
}
//longitud en el formato especificado por notationType(boolean)
float GPS_5Hz::getLongitude()
{
	float longitud = 0.0;
	if(notation == MINUTES) longitud = longitude;
	else if(notation == DECIMALS) longitud = float(getDegrees(LONGITUDE))*100 + getMinutes(LONGITUDE)*100/60;
	return longitud;
}
Beispiel #9
0
bool VCClock::saveXML(QDomDocument* doc, QDomElement* vc_root)
{
    QDomElement root;

    Q_ASSERT(doc != NULL);
    Q_ASSERT(vc_root != NULL);

    /* VC Clock entry */
    root = doc->createElement(KXMLQLCVCClock);
    vc_root->appendChild(root);

    /* Type */
    ClockType type = clockType();
    root.setAttribute(KXMLQLCVCClockType, typeToString(type));
    if (type == Countdown)
    {
        root.setAttribute(KXMLQLCVCClockHours, getHours());
        root.setAttribute(KXMLQLCVCClockMinutes, getMinutes());
        root.setAttribute(KXMLQLCVCClockSeconds, getSeconds());
    }

    saveXMLCommon(doc, &root);

    /* Window state */
    saveXMLWindowState(doc, &root);

    /* Appearance */
    saveXMLAppearance(doc, &root);

    foreach(VCClockSchedule sch, schedules())
        sch.saveXML(doc, &root);

    return true;
}
Beispiel #10
0
//latitud en el formato especificado por notationType(boolean)
float GPS_5Hz::getLatitude()
{
	float latitud = 0;
	if(notation == MINUTES) latitud = latitude;
	else if(notation == DECIMALS) latitud = float(getDegrees(LATITUDE))*100 + getMinutes(LATITUDE)*100/60;
	return latitud;
}
Beispiel #11
0
unsigned long long Date::getSeconds(long y,long m,long d, long hh, long mi, long ss) const
{
	long g = getMinutes(y,m,d,hh,mi);
	int sfm = ss/60;
	ss = ss%60;
	return (g+sfm)*60 + ss;
}
Beispiel #12
0
ostream& Time::putDataInStream( ostream& os) const {
//put (semi-formatted) time (H:M:S) into an output stream
	os << getHours() << ":";
	os << getMinutes() << ":";
	os << getSeconds();
	return os;
}
Beispiel #13
0
/**
 * Die Uhrzeit auslesen und in den Variablen ablegen
 */
void MyRTC::readTime() {
    byte returnStatus, count, result, retries = 0;
    do {
        // Reset the register pointer
        Wire.beginTransmission(_address);
        Wire.write((uint8_t) 0x00);
        result = Wire.endTransmission(false); // false, damit der Bus nicht freigegeben wird und eventuell andere dazwischen kommen (in Multi-MCU-Umgebungen)
        DEBUG_PRINT(F("Wire.endTransmission(false) = "));
        DEBUG_PRINTLN(result);

        count = Wire.requestFrom(_address, 7);
        DEBUG_PRINT(F("Wire.requestFrom(_address, 7) = "));
        DEBUG_PRINTLN(count);
        DEBUG_FLUSH();

        if (count == 7) {
            // Success
            // A few of these need masks because certain bits are control bits
            _seconds = bcdToDec(Wire.read() & 0x7f);
            _minutes = bcdToDec(Wire.read());
            _hours = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12 hour am/pm
            _dayOfWeek = bcdToDec(Wire.read());
            _date = bcdToDec(Wire.read());
            _month = bcdToDec(Wire.read());
            _year = bcdToDec(Wire.read());
        } else {
            // Fail
            // keine 7 Byte zurueck gekommen? Buffer verwerfen...
            for (int i = 0; i < count; i++) {
                Wire.read();
            }
            retries++;
        }

        result = Wire.endTransmission(true); // true, jetzt den Bus freigeben.
        DEBUG_PRINT(F("Wire.endTransmission(true) = "));
        DEBUG_PRINTLN(result);
    } while ((count != 7) && (retries < 8));

    if (retries == 8) {
        // Es konnte nichts gelesen werden
        _seconds = 11;
        _minutes = 11;
        _hours = 11;
        _dayOfWeek = 1;
        _date = 1;
        _month = 1;
        _year = 2014;
    }

    DEBUG_PRINT(F("Time: "));
    DEBUG_PRINT(getHours());
    DEBUG_PRINT(F(":"));
    DEBUG_PRINT(getMinutes());
    DEBUG_PRINT(F(":"));
    DEBUG_PRINTLN(getSeconds());
    DEBUG_FLUSH();
}
Beispiel #14
0
ostream& Time::putDataInStream( ostream& os) const {
//put digital clock formatted time ("HH:MM:SS") into an output stream
	os << setfill('0');
	os << setw(2) << getHours() << ":";
	os << setw(2) << getMinutes() << ":";
	os << setw(2) << getSeconds();
	os << setfill(' ');
	return os;
}
Beispiel #15
0
const string Time::toFormattedString() const {
//return time formatted output ("HH:MM:SS")
	ostringstream os_time;
	os_time << setfill('0');
	os_time << setw(2) << getHours()   << ":";
	os_time << setw(2) << getMinutes() << ":";
	os_time << setw(2) << getSeconds();
	return ( os_time.str());
}
Beispiel #16
0
void printPrettyTime()
{
    tcputs(itoa(getHours()),COLOR_WHITE);
    tcputs(":",COLOR_WHITE);
    tcputs(itoa(getMinutes()),COLOR_WHITE);
    tcputs(":",COLOR_WHITE);
    tcputs(itoa(getSeconds()),COLOR_WHITE);
    tputs("\n");
}
Beispiel #17
0
Seconds *Period::toStandardSeconds() {
    checkYearsAndMonths("Seconds");
    int64_t seconds = getMillis() / DateTimeConstants::MILLIS_PER_SECOND;
    seconds = FieldUtils::safeAdd(seconds, (int64_t) getSeconds());
    seconds = FieldUtils::safeAdd(seconds, ((int64_t) getMinutes()) * ((int64_t) DateTimeConstants::SECONDS_PER_MINUTE));
    seconds = FieldUtils::safeAdd(seconds, ((int64_t) getHours()) * ((int64_t) DateTimeConstants::SECONDS_PER_HOUR));
    seconds = FieldUtils::safeAdd(seconds, ((int64_t) getDays()) * ((int64_t) DateTimeConstants::SECONDS_PER_DAY));
    seconds = FieldUtils::safeAdd(seconds, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::SECONDS_PER_WEEK));
    return Seconds::seconds(FieldUtils::safeToInt(seconds));
}
Beispiel #18
0
Weeks *Period::toStandardWeeks() {
    checkYearsAndMonths("Weeks");
    int64_t millis = getMillis();  // assign to a int64_t
    millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND;
    millis += ((int64_t) getMinutes()) * DateTimeConstants::MILLIS_PER_MINUTE;
    millis += ((int64_t) getHours()) * DateTimeConstants::MILLIS_PER_HOUR;
    millis += ((int64_t) getDays()) * DateTimeConstants::MILLIS_PER_DAY;
    int64_t weeks = ((int64_t) getWeeks()) + millis / DateTimeConstants::MILLIS_PER_WEEK;
    return Weeks::weeks(FieldUtils::safeToInt(weeks));
}
Beispiel #19
0
void LedTimer::_setTime()
{
	unsigned short minutes = getMinutes();
	unsigned short seconds = getSeconds();

	mLedDigits[0].setNumber( minutes / 10 );
	mLedDigits[1].setNumber( minutes % 10 );
	mLedDigits[2].setNumber( seconds / 10 );
	mLedDigits[3].setNumber( seconds % 10 );
}
Beispiel #20
0
Duration *Period::toStandardDuration() {
    checkYearsAndMonths("Duration");
    int64_t millis = getMillis();  // no overflow can happen, even with Integer.MAX_VALUEs
    millis += (((int64_t) getSeconds()) * ((int64_t) DateTimeConstants::MILLIS_PER_SECOND));
    millis += (((int64_t) getMinutes()) * ((int64_t) DateTimeConstants::MILLIS_PER_MINUTE));
    millis += (((int64_t) getHours()) * ((int64_t) DateTimeConstants::MILLIS_PER_HOUR));
    millis += (((int64_t) getDays()) * ((int64_t) DateTimeConstants::MILLIS_PER_DAY));
    millis += (((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::MILLIS_PER_WEEK));
    return new Duration(millis);
}
Beispiel #21
0
char* DS1307::getTime(void)
{
	uint8_t seconds = getSeconds();
	uint8_t minutes = getMinutes();
	hours_t hours = getHours();

	snprintf(timeBuf, 10, "%02d:%02d:%02d", hours.hours, minutes, seconds);

	return timeBuf;
}
Beispiel #22
0
Minutes *Period::toStandardMinutes() {
    checkYearsAndMonths("Minutes");
    int64_t millis = getMillis();  // assign to a int64_t
    millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND;
    int64_t minutes = millis / DateTimeConstants::MILLIS_PER_MINUTE;
    minutes = FieldUtils::safeAdd(minutes, (int64_t) getMinutes());
    minutes = FieldUtils::safeAdd(minutes, ((int64_t) getHours()) * ((int64_t) DateTimeConstants::MINUTES_PER_HOUR));
    minutes = FieldUtils::safeAdd(minutes, ((int64_t) getDays()) * ((int64_t) DateTimeConstants::MINUTES_PER_DAY));
    minutes = FieldUtils::safeAdd(minutes, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::MINUTES_PER_WEEK));
    return Minutes::minutes(FieldUtils::safeToInt(minutes));
}
Beispiel #23
0
Days *Period::toStandardDays() {
    checkYearsAndMonths("Days");
    int64_t millis = getMillis();  // assign to a int64_t
    millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND;
    millis += ((int64_t) getMinutes()) * DateTimeConstants::MILLIS_PER_MINUTE;
    millis += ((int64_t) getHours()) * DateTimeConstants::MILLIS_PER_HOUR;
    int64_t days = millis / DateTimeConstants::MILLIS_PER_DAY;
    days = FieldUtils::safeAdd(days, (int64_t) getDays());
    days = FieldUtils::safeAdd(days, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::DAYS_PER_WEEK));
    return Days::days(FieldUtils::safeToInt(days));
}
Beispiel #24
0
void consoleService() {
  char ch ;

  ch = readKey();
  if ( ch < 1 ) {
    ch = readServer();
    if (ch < 1) return;
  }

  if ( controlMode(ch) ) { p(" -> %02d:%02d:%02d ", getHours(), getMinutes(), getSeconds() );  }
}
Beispiel #25
0
/* get time in string format
 * default format is:
 *		"hh:mm::ss'ddd",
 * where:
 *		hh - hour,
 *		mm - minures,
 *		ss - seconds,
 *		ddd - miliseconds.
 */
rfc::String rfc::Time::getTimeString() const {
	/*
	if (isInfinity)
		return QString("infinity");
	*/

	return
		String::toString(getHours())	+ QString(":")
	+	String::toString(getMinutes())	+ QString(":")
	+	String::toString(getSeconds())	+ QString("'")
	+	String::toString(getMilliSec());
} /* end of 'Time::getTimeString' function */
Beispiel #26
0
zstring TimeZone::toString() const {
  zstring result;
  if ( *this ) {
    if ( !gmtoff_ )
      result = 'Z';
    else {
      result += *this < 0 ? '-' : '+';
      result += zero_pad( std::abs( getHours() ), 2 );
      result += ':';
      result += zero_pad( std::abs( getMinutes() ), 2 );
    }
  }
  return result;
}
Beispiel #27
0
// returns str of length 6 (with zero symbol)
const char* getTimeStrHoursMinutes(void)
{
	static char timeStrBuff[6];

	const uint08 hours = getHours();
	timeStrBuff[0] = GET_PROGMEM_DIGIT(hours / 10);
	timeStrBuff[1] = GET_PROGMEM_DIGIT(hours % 10);
	timeStrBuff[2] = ':';
	const uint08 minutes = getMinutes();
	timeStrBuff[3] = GET_PROGMEM_DIGIT(minutes / 10);
	timeStrBuff[4] = GET_PROGMEM_DIGIT(minutes % 10);
	timeStrBuff[5] = '\0';

	return timeStrBuff;
}
Beispiel #28
0
string Time::toString() {
	stringstream h;
	h << getHours();
	stringstream m;
	m << getMinutes();
	stringstream s;
	s << getSeconds();

	string output = "";
	output += h.str();
	output += ':';
	output += m.str();
	output += ':';
	output += s.str();

	return output;
}
Beispiel #29
0
// Print the current time and A/B signal levels on the console
void showTime() {
  unsigned int s = getSeconds();

  //-- Newline + whole time every minute
  if ( s == 0 )
    p("\r\n%02u%s:%02u:%02u ", getHours(), getDST() ? "D" : "", getMinutes(), s);
  else if ( (s % 10 ) == 0)
    p("%02u", s );
  else
    p("-");

  //-- Show the A/B/D/E pulse status, F level
  if (getA()) p("A");
  if (getB()) p("B");
  if (getD()) p("D");
  if (getE()) p("E");
  if (getF()) p("F");
}
Beispiel #30
0
uint32_t RTCDue::unixtime ()
{
  uint32_t _ticks;
  uint16_t _days;
  
  _hour   = getHours ();
  _minute = getMinutes ();
  _second = getSeconds ();
  
  _day    = getDay ();
  _month  = getMonth ();
  _year   = getYear (); //4 digits
  
  // Based on https://github.com/punkiller/workspace/blob/master/string2UnixTimeStamp.cpp
  // days of the years between start of unixtime and now
  _days = 365 * (_year - 1970);
  
  // add days from switch years in between except year from date
  for( int i = 1970; i < _year; i++ ){
    if( switch_years (i) ) {
      _days++;
    }
  }
  
  // Based on https://github.com/adafruit/RTClib/blob/master/RTClib.cpp
  // add switch day from actuall year if necessary
  for ( int i = 1; i < _month; ++i )
    _days += daysInMonth[i - 1];
  
  if ( _month > 2 && switch_years (_year) )
    ++_days;
  
  _days += _day - 1;
  
  _ticks = ((_days * 24 + _hour) * 60 + _minute) * 60 + _second;
  
  return _ticks;
}