void tzset() { struct timeval tp; struct timezone tz; (void) gettimeofday(&tp, &tz); (void) strcpy(tz1, timezone(tz.tz_minuteswest, 0)); (void) strcpy(tz2, timezone(tz.tz_minuteswest, 1)); daylight = tz.tz_dsttime; }
List maxmind_bindings::lookup(std::vector < std::string >& ip_addresses, MMDB_s *mmdb_set, std::vector < std::string > fields){ List output; int field_length = fields.size(); for(int i = 0; i < field_length; i++){ if(fields[i] == "continent_name"){ output.push_back(continent_name(mmdb_set, ip_addresses)); } else if(fields[i] == "country_name"){ output.push_back(country_name(mmdb_set, ip_addresses)); } else if(fields[i] == "country_code"){ output.push_back(country_code(mmdb_set, ip_addresses)); } else if(fields[i] == "region_name"){ output.push_back(region_name(mmdb_set, ip_addresses)); } else if(fields[i] == "city_name"){ output.push_back(city_name(mmdb_set, ip_addresses)); } else if(fields[i] == "timezone"){ output.push_back(timezone(mmdb_set, ip_addresses)); } else if(fields[i] == "latitude"){ output.push_back(latitude(mmdb_set, ip_addresses)); } else if(fields[i] == "longitude"){ output.push_back(longitude(mmdb_set, ip_addresses)); } else if(fields[i] == "connection"){ output.push_back(connection(mmdb_set, ip_addresses)); } } return output; }
/* * Unix Date */ char *udate() { static char out[40]; long now; struct tm *t; #ifdef VMUNIX struct timeb tb; ftime(&tb); t = localtime(&tb.time); #else time(&now); t = localtime(&now); #endif sprintf(out, "%3.3s %3.3s %2d %02d:%02d:%02d %3.3s %4d", wdays[t->tm_wday], months[t->tm_mon], t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, #ifdef VMUNIX timezone(tb.timezone, tb.dstflag), #else tzname[daylight], /* Name of local timezone */ #endif 1900 + t->tm_year ); return out; }
void MLocationDatabaseFake::createCities() { QMap<QString, QString>* countries = countriesMap(); QMap<QString, QString>::const_iterator iter; for(iter = countries->begin(); iter != countries->end(); iter++) { UErrorCode status = U_ZERO_ERROR; icu::StringEnumeration* tzids = icu::TimeZone::createEnumeration( iter.key().toAscii().data()); const UnicodeString *next; for(next = tzids->snext(status);next;next = tzids->snext(status)) { QString timezone(reinterpret_cast<const QChar*>( next->getBuffer()), next->length()); qDebug() << timezone; /* skip timezone names like: GB-Eire * and hold only ones like: Area/City */ if(!timezone.contains("/")) continue; QString countryName = iter.value(); countryName.replace("\n", ""); addCity(timezone, countryName); } } }
char *zone_name(const struct tm *tp) { char *timezone(); struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return timezone(tz.tz_minuteswest, tp->tm_isdst); }
int main(int argc, char *argv[]) { register char *tzn; struct timeb info; int wf, rc; rc = 0; ftime(&info); if (argc>1 && argv[1][0]=='-' && argv[1][1]=='u') { argc--; argv++; uflag++; } if(argc > 1) { ap = argv[1]; if (gtime()) { printf("date: bad conversion\n"); exit(1); } /* convert to GMT assuming local time */ if (uflag==0) { timbuf += (long)info.timezone*60; /* now fix up local daylight time */ if(localtime(&timbuf)->tm_isdst) timbuf -= 60*60; } time(&timevalue); wtmp[0].ut_time = timevalue; if(stime(&timbuf) < 0) { rc++; printf("date: no permission\n"); // TODO: check! } else if ((wf = open("/usr/adm/wtmp", O_WRONLY|O_CREAT|O_APPEND)) >= 0) { wtmp[1].ut_time = timevalue; //lseek(wf, 0L, 2); write(wf, (char *)wtmp, sizeof(wtmp)); close(wf); } } if (rc==0) time(&timbuf); if(uflag) { ap = asctime(gmtime(&timbuf)); tzn = "GMT"; } else { struct tm *tp; tp = localtime(&timbuf); ap = asctime(tp); tzn = timezone(info.timezone, tp->tm_isdst); } printf("%.20s", ap); if (tzn) printf("%s", tzn); printf("%s", ap+19); exit(rc); }
TEST(gnc_timezone_constructors, test_posix_timezone) { std::string timezone("FST08FDT07,M4.1.0,M10.31.0"); TimeZoneProvider tzp(timezone); TZ_Ptr tz = tzp.get(2006); EXPECT_TRUE(tz->std_zone_abbrev() == "FST"); EXPECT_TRUE(tz->dst_zone_abbrev() == "FDT"); EXPECT_TRUE(tz->base_utc_offset().hours() == 8L); EXPECT_TRUE(tz->dst_offset().hours() == 7L); }
/* * ARPA-styled date * RFC822 format 'Sun, 20 Nov 91 17:35:54 PST\0' or * 'Fri, 26 May 85 02:13:10 -0700 (PST)\0' */ char *adate() { static char out[50]; long now; struct tm *t; int tzshift; char tzsign; #if defined(VMUNIX) || defined(demos) struct timeb tb; ftime(&tb); t = localtime(&tb.time); tzshift = tb.timezone; #else /* not VMUNIX */ time(&now); t = localtime(&now); #ifdef M_XENIX tzshift = t->tm_tzadj/60; #else tzshift = timezone/60; #endif #endif /* not VMUNIX */ tzsign = tzshift <= 0 ? '+' : '-'; if( tzshift < 0 ) tzshift = -tzshift; tzshift = 100*(tzshift/60) + (tzshift%60); sprintf(out, "%3.3s, %2d %3.3s %2d %02d:%02d:%02d %c%04d (%s)", wdays[t->tm_wday], t->tm_mday, months[t->tm_mon], t->tm_year % 100, t->tm_hour, t->tm_min, t->tm_sec, tzsign, #if defined(VMUNIX) || defined(demos) tzshift + (tb.dstflag != 0)*100, timezone(tb.timezone, tb.dstflag) #else tzshift, tzname[t->tm_isdst] /* Name of local timezone */ #endif ); return out; }
TEST(gnc_timezone_constructors, test_pacific_time_constructor) { #if PLATFORM(WINDOWS) std::string timzone("Pacific Standard Time"); #else std::string timezone("America/Los_Angeles"); #endif TimeZoneProvider tzp (timezone); EXPECT_NO_THROW (tzp.get(2006)); TZ_Ptr tz = tzp.get (2006); EXPECT_FALSE(tz->std_zone_abbrev().empty()); #if PLATFORM(WINDOWS) EXPECT_TRUE(tz->std_zone_abbrev() == timezone); #else EXPECT_TRUE(tz->std_zone_abbrev() == "PST"); EXPECT_TRUE(tz->dst_zone_abbrev() == "PDT"); #endif EXPECT_TRUE(tz->base_utc_offset().hours() == -8); }
/* FIXME: most of the #ifdefs here should be based on configure checks instead. Same for rusage() */ void f_localtime (void) { struct tm *tm; array_t *vec; time_t lt; #ifdef sequent struct timezone tz; #endif lt = sp->u.number; tm = localtime(<); vec = allocate_empty_array(11); vec->item[LT_SEC].type = T_NUMBER; vec->item[LT_SEC].u.number = tm->tm_sec; vec->item[LT_MIN].type = T_NUMBER; vec->item[LT_MIN].u.number = tm->tm_min; vec->item[LT_HOUR].type = T_NUMBER; vec->item[LT_HOUR].u.number = tm->tm_hour; vec->item[LT_MDAY].type = T_NUMBER; vec->item[LT_MDAY].u.number = tm->tm_mday; vec->item[LT_MON].type = T_NUMBER; vec->item[LT_MON].u.number = tm->tm_mon; vec->item[LT_YEAR].type = T_NUMBER; vec->item[LT_YEAR].u.number = tm->tm_year + 1900; vec->item[LT_WDAY].type = T_NUMBER; vec->item[LT_WDAY].u.number = tm->tm_wday; vec->item[LT_YDAY].type = T_NUMBER; vec->item[LT_YDAY].u.number = tm->tm_yday; vec->item[LT_GMTOFF].type = T_NUMBER; vec->item[LT_ZONE].type = T_STRING; vec->item[LT_ZONE].subtype = STRING_MALLOC; vec->item[LT_ISDST].type = T_NUMBER; #if defined(BSD42) || defined(apollo) || defined(_AUX_SOURCE) \ || defined(OLD_ULTRIX) /* 4.2 BSD doesn't seem to provide any way to get these last three values */ vec->item[LT_GMTOFF].u.number = 0; vec->item[LT_ZONE].type = T_NUMBER; vec->item[LT_ZONE].u.number = 0; vec->item[LT_ISDST].u.number = -1; #else /* BSD42 */ vec->item[LT_ISDST].u.number = tm->tm_isdst; #if defined(sequent) vec->item[LT_GMTOFF].u.number = 0; gettimeofday(NULL, &tz); vec->item[LT_GMTOFF].u.number = tz.tz_minuteswest; vec->item[LT_ZONE].u.string = string_copy(timezone(tz.tz_minuteswest, tm->tm_isdst), "f_localtime"); #else /* sequent */ #if (defined(hpux) || defined(_SEQUENT_) || defined(_AIX) || defined(SunOS_5) \ || defined(SVR4) || defined(sgi) || defined(linux) || defined(cray) \ || defined(LATTICE) || defined(SCO)) if (!tm->tm_isdst) { vec->item[LT_GMTOFF].u.number = timezone; vec->item[LT_ZONE].u.string = string_copy(tzname[0], "f_localtime"); } else { #if (defined(_AIX) || defined(hpux) || defined(linux) || defined(cray) \ || defined(LATTICE)) vec->item[LT_GMTOFF].u.number = timezone; #else vec->item[LT_GMTOFF].u.number = altzone; #endif vec->item[LT_ZONE].u.string = string_copy(tzname[1], "f_localtime"); } #else #ifndef WIN32 vec->item[LT_GMTOFF].u.number = tm->tm_gmtoff; vec->item[LT_ZONE].u.string = string_copy(tm->tm_zone, "f_localtime"); #else vec->item[LT_GMTOFF].u.number = _timezone; vec->item[LT_ZONE].u.string = string_copy(_tzname[_daylight?1:0],"f_localtime"); #endif #endif #endif /* sequent */ #endif /* BSD42 */ put_array(vec); }
double Weather::sin_solar_elevation_angle (const Time& time) const // [] { return Astronomy::SinSolarElevationAngle (time, latitude (), longitude (), timezone ()); }
double Weather::extraterrestrial_radiation (const Time& time) const // [W/m2] { return Astronomy::ExtraterrestrialRadiation (time, latitude (), longitude (), timezone ()); }
QString Wpp::timezoneShortName(qint64 msecsSinceEpoch, const QString& ianaId) { QTimeZone timezone(ianaId.toLatin1()); qDebug() << __FUNCTION__ << ":shortname=" << timezone.displayName(QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch), QTimeZone::ShortName); return timezone.displayName(QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch), QTimeZone::ShortName); }
QString Wpp::timezoneAbbreviation(qint64 msecsSinceEpoch, const QString& ianaId) { QTimeZone timezone(ianaId.toLatin1()); return timezone.abbreviation(QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch)); }
QString Wpp::timezoneLongName(qint64 msecsSinceEpoch, const QString& ianaId, const QLocale& locale) { QTimeZone timezone(ianaId.toLatin1()); qDebug() << __FUNCTION__ << ":longname=" << timezone.displayName(QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch), QTimeZone::LongName); return timezone.displayName(QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch), QTimeZone::LongName, locale); }
char *arpadate(register char *ud) { register char *p; register char *q; static char b[40]; extern char *ctime(); register int i; #ifndef BSD extern char *tzname[]; time_t t, time(); #else /* V7 and 4BSD */ struct timeb t; extern struct timeb *ftime(); extern char *timezone(); #endif /* ** Get current time. ** This will be used if a null argument is passed and ** to resolve the timezone. */ #ifndef BSD (void) time(&t); if (ud == NULL) ud = ctime(&t); #else /* V7 or 4BSD */ ftime(&t); if (ud == NULL) ud = ctime(&t.time); #endif /* ** Crack the UNIX date line in a singularly unoriginal way. */ q = b; p = &ud[8]; /* 16 */ if (*p == ' ') p++; else *q++ = *p++; *q++ = *p++; *q++ = ' '; p = &ud[4]; /* Sep */ *q++ = *p++; *q++ = *p++; *q++ = *p++; *q++ = ' '; p = &ud[22]; /* 1979 */ *q++ = *p++; *q++ = *p++; *q++ = ' '; p = &ud[11]; /* 01:03:52 */ for (i = 8; i > 0; i--) *q++ = *p++; /* -PST or -PDT */ #ifndef BSD p = tzname[localtime(&t)->tm_isdst]; #else p = timezone(t.timezone, localtime(&t.time)->tm_isdst); #endif if (p[3] != '\0') { /* hours from GMT */ p += 3; *q++ = *p++; if (p[1] == ':') *q++ = '0'; else *q++ = *p++; *q++ = *p++; p++; /* skip ``:'' */ *q++ = *p++; *q++ = *p++; } else { *q++ = ' '; *q++ = *p++; *q++ = *p++; *q++ = *p++; } p = &ud[0]; /* Mon */ *q++ = ' '; *q++ = '('; *q++ = *p++; *q++ = *p++; *q++ = *p++; *q++ = ')'; *q = '\0'; return (b); }
/*規則�@ <文>→<地区><時間帯><天気>*/ void sentence() { region() ;//地区の生成 timezone() ;//時間帯の生成 weather();//天気の生成 }