void parsetimezone(char* content) { int timezone = atoi(content); //parsing string to int (only works when everything is int) if(strlen(content) == 0) { setTimeZone(50); } else { setTimeZone(timezone); } }
inline bool setTimeZones(MessageFormatter* data) { if (!data->usesDate() || data->isTzSet()) { return true; } int32_t count; auto obj = data->formatterObj(); auto formats = obj->getFormats(count); if (!formats) { data->setError(U_MEMORY_ALLOCATION_ERROR, "Out of memory retrieving subformats"); return false; } icu::TimeZone *tz = nullptr; SCOPE_EXIT{ if (tz) { delete tz; } }; for (int i = 0; i < count; ++i) { auto df = dynamic_cast<icu::DateFormat*>( const_cast<icu::Format *>(formats[i])); if (!df) { continue; } if (!tz) { tz = IntlTimeZone::ParseArg(uninit_null(), "msgfmt_format", data); if (U_FAILURE(data->getErrorCode())) { return false; } } if (tz) { df->setTimeZone(*tz); } } data->tzSet(true); return true; }
void JPWiFly::setNTP(const char* adr, uint16_t port, uint8_t zone, uint16_t period) { StCommand cmd(this); setTimeAddress(adr); setTimePort(port); setTimeZone(zone); setTimeEnable(period); }
bool WeatherDataModel::readLocation(QString line) { QStringList list = line.split(','); // Require 10 items in the list if(list.size() > 10) { LOG(warning) << "Location: Expected 10 entries, got " << list.size(); } else if(list.size() != 10) { LOG(error) << "Location: Expected 10 entries, got " << list.size(); return false; } setCity(list[1].toStdString()); setStateProvinceRegion(list[2].toStdString()); setCountry(list[3].toStdString()); setSource(list[4].toStdString()); setWMO(list[5].toStdString()); if(!setLatitude(list[6].toStdString())) { LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[6]).toStdString(); return false; } if(!setLongitude(list[7].toStdString())) { LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[7]).toStdString(); return false; } if(!setTimeZone(list[8].toStdString())) { LOG(error) << QString("Location: Bad time zone value '%1'").arg(list[8]).toStdString(); return false; } if(!setElevation(list[9].toStdString())) { LOG(error) << QString("Location: Bad elevation value '%1'").arg(list[9]).toStdString(); return false; } return true; }
/* pargs[1] -> tz */ void callSetTimeZone(int cargs, void ** pargs) { int tz = pargs[1]; if(tz>=-12 && tz<=12) { setTimeZone(tz); printf("\nTime set correctly to GTM %d \n",tz); } else{ printf("\nInput error\n"); } }
TimeSource::TimeSource(const QString &name, QObject *parent) : Plasma::DataContainer(parent), m_offset(0), m_latitude(0), m_longitude(0), m_sun(0), m_moon(0), m_moonPosition(false), m_solarPosition(false), m_local(false) { setObjectName(name); setTimeZone(parseName(name)); }
void initShell() { //clearScreen(); printf("-- WELCOME THE SHELL --\n\n >>"); setTimeZone(-3); setConsoleSize(); shellBuffer = sbuffer[0]; cleanBuffer(); while(1) { int c = getc(); if (c != EOF) { if (c == '\n') { execute(); } else if (c == '\b') { removeKey(); } else { addToShellBuffer(c); putc(c); } } } }
int NtpSync(void){ /* Ophalen van pool.ntp.org */ isSyncing = true; setTimeZone(50); httpGet("/gettimezone.php", parsetimezone); _daylight = 0; printf("Timezone is: %d", TIME_ZONE); if(TIME_ZONE == 50) { return 0; } NutDelay(100); //puts("Tijd ophalen van pool.ntp.org (213.154.229.24)"); timeserver = inet_addr("213.154.229.24"); for (;;) { if (NutSNTPGetTime(×erver, &ntp_time) == 0) { break; } else { NutSleep(400); puts("Fout bij het ontvangen van de tijd"); } } //puts("Opgehaald.\n"); ntp_datetime = localtime(&ntp_time); printf("NTP time is: %02d:%02d:%02d\n", ntp_datetime->tm_hour, ntp_datetime->tm_min, ntp_datetime->tm_sec); printf("NTP date is: %02d.%02d.%02d\n\n", ntp_datetime->tm_mday, (ntp_datetime->tm_mon + 1), (ntp_datetime->tm_year + 1900)); X12RtcSetClock(ntp_datetime); NtpWriteTimeToEeprom(*ntp_datetime); isSyncing = false; validTime = true; return 1; }
void OEvent::fromMap( const QMap<int, QString>& map ) { // We just want to set the UID if it is really stored. if ( !map[OEvent::FUid].isEmpty() ) setUid( map[OEvent::FUid].toInt() ); setCategories( idsFromString( map[OEvent::FCategories] ) ); setDescription( map[OEvent::FDescription] ); setLocation( map[OEvent::FLocation] ); if ( map[OEvent::FType] == "AllDay" ) setAllDay( true ); else setAllDay( false ); int alarmTime = -1; if( !map[OEvent::FAlarm].isEmpty() ) alarmTime = map[OEvent::FAlarm].toInt(); int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); if ( ( alarmTime != -1 ) ){ QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); OPimAlarm al( sound , dt ); notifiers().add( al ); } if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ setTimeZone( map[OEvent::FTimeZone] ); } time_t start = (time_t) map[OEvent::FStart].toLong(); time_t end = (time_t) map[OEvent::FEnd].toLong(); /* AllDay is always in UTC */ if ( isAllDay() ) { OTimeZone utc = OTimeZone::utc(); setStartDateTime( utc.fromUTCDateTime( start ) ); setEndDateTime ( utc.fromUTCDateTime( end ) ); setTimeZone( "UTC"); // make sure it is really utc }else { /* to current date time */ // qWarning(" Start is %d", start ); OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); QDateTime date = zone.toDateTime( start ); qWarning(" Start is %s", date.toString().latin1() ); setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); date = zone.toDateTime( end ); setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); } if ( !map[OEvent::FRecParent].isEmpty() ) setParent( map[OEvent::FRecParent].toInt() ); if ( !map[OEvent::FRecChildren].isEmpty() ){ QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { addChild( (*it).toInt() ); } } // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. if( !map[OEvent::FRType].isEmpty() ){ QMap<int, QString> recFields; recFields.insert( ORecur::RType, map[OEvent::FRType] ); recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); recFields.insert( ORecur::RFreq, map[OEvent::FRFreq] ); recFields.insert( ORecur::RHasEndDate, map[OEvent::FRHasEndDate] ); recFields.insert( ORecur::EndDate, map[OEvent::FREndDate] ); recFields.insert( ORecur::Created, map[OEvent::FRCreated] ); recFields.insert( ORecur::Exceptions, map[OEvent::FRExceptions] ); ORecur recur( recFields ); setRecurrence( recur ); } }