X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f49d731fd4dc46cf729e3f9f4397d6080ee6d0dd..aa99e0cd2242db04fe1f9bb7d91aea545def2422:/src/common/datetime.cpp diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 7ea7a574e3..2b208928df 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -1287,6 +1287,17 @@ wxDateTime& wxDateTime::Set(double jdn) jdn *= MILLISECONDS_PER_DAY; + // JDNs always suppose an UTC date, so bring it back to local time zone + // (also see GetJulianDayNumber() implementation) + long tzDiff = GetTimeZone(); + if ( IsDST() == 1 ) + { + // FIXME: again, we suppose that DST is always one hour + tzDiff -= 3600; + } + + jdn += tzDiff*1000; // tzDiff is in seconds + m_time.Assign(jdn); return *this; @@ -1326,6 +1337,7 @@ wxDateTime& wxDateTime::ResetTime() wxDateTime& wxDateTime::SetFromDOS(unsigned long ddt) { struct tm tm; + InitTm(tm); long year = ddt & 0xFE000000; year >>= 25; @@ -1903,8 +1915,8 @@ wxDateTime& wxDateTime::SetToYearDay(wxDateTime::wxDateTime_t yday) double wxDateTime::GetJulianDayNumber() const { - // JDN are always expressed for the GMT dates - Tm tm(ToTimezone(GMT0).GetTm(GMT0)); + // JDN are always expressed for the UTC dates + Tm tm(ToTimezone(UTC).GetTm(UTC)); double result = GetTruncatedJDN(tm.mday, tm.mon, tm.year);