X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/37424888b883ba2434066cfa559d3d96a5ac8723..8fdbcf4de8eeff67ccfaf3deec833d203f112629:/src/common/datetimefmt.cpp diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 3e51672eee..69cc996454 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -514,7 +514,7 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const // (indirectly) set the year correctly while ( (nLostWeekDays % 7) != 0 ) { - nLostWeekDays += year++ % 4 ? 1 : 2; + nLostWeekDays += (year++ % 4) ? 1 : 2; } // finally move the year below 2000 so that the 2-digit @@ -655,6 +655,18 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const case wxT('z'): // time zone as [-+]HHMM { int ofs = tz.GetOffset(); + + // The time zone offset does not include the DST, but + // we do need to take it into account when showing the + // time in the local time zone to the user. + if ( ofs == -wxGetTimeZone() && IsDST() == 1 ) + { + // FIXME: As elsewhere in wxDateTime, we assume + // that the DST is always 1 hour, but this is not + // true in general. + ofs += 3600; + } + if ( ofs < 0 ) { res += '-'; @@ -1725,12 +1737,12 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end) if ( len > lenRest ) continue; - const wxString::const_iterator pEnd = p + len; - if ( wxString(p, pEnd).CmpNoCase(dateStr) == 0 ) + const wxString::const_iterator pEndStr = p + len; + if ( wxString(p, pEndStr).CmpNoCase(dateStr) == 0 ) { // nothing can follow this, so stop here - p = pEnd; + p = pEndStr; int dayDiffFromToday = literalDates[n].dayDiffFromToday; *this = Today(); @@ -1739,7 +1751,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end) *this += wxDateSpan::Days(dayDiffFromToday); } - *end = pEnd; + *end = pEndStr; return true; } @@ -2105,6 +2117,8 @@ wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end) "%H:%M:%S", // could be the same or 24 hour one so try it too "%I:%M %p", // 12hour with AM/PM but without seconds "%H:%M", // and a possibly 24 hour version without seconds + "%I %p", // just hour with AM/AM + "%H", // just hour in 24 hour version "%X", // possibly something from above or maybe something // completely different -- try it last