Merge branch 'tz-fixes'

Miscellaneous fixes for time zones and DST handling in wxDateTime.

This still leaves 2 big problems:

1. We have no support for using the correct time zone offset at the
   given date and always use the current time zone offset, which may,
   and often is, wrong.

2. Our code for converting to/from broken down representation doesn't
   handle DST at all, so support for DST is non-existent for the dates
   before 1970-01-01 or after 2038-01-01 (i.e. roughly outside of the
   32 bit time_t range).

See #10445 and the other tickets linked from there.
This commit is contained in:
Vadim Zeitlin
2017-12-02 16:28:05 +01:00
8 changed files with 215 additions and 133 deletions

View File

@@ -306,7 +306,9 @@ public:
return tz;
}
long GetOffset() const { return m_offset; }
bool IsLocal() const { return m_offset == -1; }
long GetOffset() const;
private:
// offset for this timezone from GMT in seconds

View File

@@ -158,7 +158,11 @@ public:
line = line_;
component = component_;
timestamp = time(NULL);
// don't initialize the timestamp yet, we might not need it at all if
// the message doesn't end up being logged and otherwise we'll fill it
// just before logging it, which won't change it by much and definitely
// less than a second resolution of the timestamp
timestamp = 0;
#if wxUSE_THREADS
threadId = wxThread::GetCurrentId();
@@ -1162,6 +1166,11 @@ private:
void DoCallOnLog(wxLogLevel level, const wxString& format, va_list argptr)
{
// As explained in wxLogRecordInfo ctor, we don't initialize its
// timestamp to avoid calling time() unnecessary, but now that we are
// about to log the message, we do need to do it.
m_info.timestamp = time(NULL);
wxLog::OnLog(level, wxString::FormatV(format, argptr), m_info);
}