i'm lost with ParseDate and FormatDate (wx2.9)
Vadim Zeitlin
vadim at wxwidgets.org
Fri Feb 1 11:34:16 PST 2008
On Fri, 01 Feb 2008 10:21:56 +0100 Riccardo Cohen <rcohen at articque.com> wrote:
RC> I don't know if I'm missing something, but it seems that ParseDate and
RC> FormatDate do not work correcly together.
ParseDate() uses heuristics for parsing dates and so is incapable of
parsing 01/06 correctly in both US and Europe. Maybe we can make this more
accurate by looking at the month/day order in %x but it still won't be
perfect. If you know that your date is going to be in the system format,
use ParseFormat("%x"). And if you know that it's going to be in some fixed
format, use ParseFormat() with it.
RC> tmpd=wxT("01/07/2000");
RC> str+=wxString::Format(wxT("string is %s\n"),tmpd);
RC> adate.ParseFormat((const wxChar *)tmpd,wxT("%x"));
RC> str+=wxString::Format(wxT("Month is %d Year is
RC> %d\n"),adate.GetMonth(),adate.GetYear());
RC> tmpd=adate.Format(wxT("%x"));
RC> str+=wxString::Format(wxT("Format is %s\n"),tmpd);
RC> adate.ParseFormat((const wxChar *)tmpd,wxT("%x"));
RC> str+=wxString::Format(wxT("Month is %d Year is
RC> %d\n"),adate.GetMonth(),adate.GetYear());
RC> tmpd=adate.Format(wxT("%x"));
RC> str+=wxString::Format(wxT("Format is %s\n\n"),tmpd);
...
RC> Results : FR WINDOWS
RC> --------------------
...
RC> Parse %x/Format %x
RC> string is 01/07/2000
RC> Month is 6 Year is 2000
RC> Format is 01/07/2000
RC> Month is 6 Year is 2000
RC> Format is 01/07/2000
RC>
RC> ===> OK
RC>
RC> Results : GB WINDOWS
RC> --------------------
...
RC> Parse %x/Format %x
RC> string is 01/07/2000
RC> Month is 6 Year is 2000
RC> Format is 01/07/2000
RC> Month is 6 Year is 2000
RC> Format is 01/07/2000
RC>
RC> ===> #BAD month is the second numbe
I don't understand why is this bad. The result is exactly the same as for
French Windows above.
RC> Results : FR MACOSX
RC> --------------------
RC> ParseDate/FormatDate
...
RC> Parse %x/Format %x
RC> string is 01/07/2000
RC> Month is 6 Year is 2020
RC> Format is 01.07.2020
RC> Month is 6 Year is 2020
RC> Format is 01.07.2020
RC>
RC> ===> #BAD year not parsed correctly
This looks like a serious bug. I don't know where does it come from but
this should definitely be fixed...
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list