Consistently handle DST start time in wxDateTime::Set().

Always move the dates invalid due to DST (i.e. falling into the "missing" hour
on the DST start date) forward, as GNU libc does, even when using a different
CRT implementation, such as MSVC one which moves the invalid dates backwards.

This seems more expected and also fixes an especially bad problem which
happened due to moving the date backwards in Brazilian time zone where DST
starts at midnight as doing this changed the day and totally broke ParseDate()
assumption that setting wxDateTime to 00:00:00 at the given date really did
set it to this date.

Closes #15419.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-09-08 18:00:58 +00:00
parent d9b22d8fff
commit 17d698cca5
4 changed files with 57 additions and 2 deletions

View File

@@ -389,11 +389,25 @@ public:
/**
Sets the date to be equal to Today() and the time from supplied
parameters.
See the full Set() overload for the remarks about DST.
*/
wxDateTime& Set(wxDateTime_t hour, wxDateTime_t minute = 0,
wxDateTime_t second = 0, wxDateTime_t millisec = 0);
/**
Sets the date and time from the parameters.
If the function parameters are invalid, e.g. @a month is February and
@a day is 30, the object is left in an invalid state, i.e. IsValid()
method will return @false.
If the specified time moment is invalid due to DST, i.e. it falls into
the "missing" hour on the date on which the DST starts, a valid
wxDateTime object is still constructed but its hour component is moved
forward to ensure that it corresponds to a valid moment in the local
time zone. For example, in the CET time zone the DST started on
2013-03-31T02:00:00 in 2013 and so setting the object to 2:30 at this
date actually sets the hour to 3, and not 2.
*/
wxDateTime& Set(wxDateTime_t day, Month month,
int year = Inv_Year, wxDateTime_t hour = 0,