void LocalDateTime::determineTzd(bool adjust) { if (adjust) { std::time_t epochTime = _dateTime.timestamp().epochTime(); #if defined(_WIN32) || defined(POCO_NO_POSIX_TSF) #if defined(_WIN32_WCE) std::tm* broken = wceex_localtime(&epochTime); #else std::tm* broken = std::localtime(&epochTime); #endif if (!broken) throw Poco::SystemException("cannot get local time"); _tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0)); #else std::tm broken; #if defined(POCO_VXWORKS) if (localtime_r(&epochTime, &broken) != OK) throw Poco::SystemException("cannot get local time"); #else if (!localtime_r(&epochTime, &broken)) throw Poco::SystemException("cannot get local time"); #endif _tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0)); #endif adjustForTzd(); } else { int dst; dstOffset(dst); _tzd = (Timezone::utcOffset() + dst); } }
LocalDateTime& LocalDateTime::assign(int tzd, double julianDay) { _tzd = tzd; _dateTime = julianDay; adjustForTzd(); return *this; }
LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime, bool adjust): _dateTime(dateTime), _tzd(tzd) { if (adjust) adjustForTzd(); }
void LocalDateTime::determineTzd(bool adjust) { std::time_t local; std::tm broken; broken.tm_year = (_dateTime.year() - 1900); broken.tm_mon = (_dateTime.month() - 1); broken.tm_mday = _dateTime.day(); broken.tm_hour = _dateTime.hour(); broken.tm_min = _dateTime.minute(); broken.tm_sec = _dateTime.second(); broken.tm_isdst = -1; local = std::mktime(&broken); _tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0)); if (adjust) adjustForTzd(); }
LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime): _dateTime(dateTime), _tzd(tzd) { adjustForTzd(); }
LocalDateTime::LocalDateTime(int tzd, double julianDay): _dateTime(julianDay), _tzd(tzd) { adjustForTzd(); }
LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff, int tzd): _dateTime(utcTime, diff), _tzd(tzd) { adjustForTzd(); }