Discussion:
wxDateTime.Format issue???
Ralph Pass
2014-03-25 20:34:36 UTC
Permalink
I am running on a Mac, Mavericks, wxWidgets 3.0.0.

I modify the sample program drawing to add:

wxDateTime t = wxDateTime::Now();
wxString timeText = t.Format();

before the last DrawText call in the DrawText method and then change the last DrawText call to be:

dc.DrawText("And\nmore\ntext on\nmultiple\nlines\n\n" + timeText, 110, y);


The text that is displayed is: Tuesday, March 25, 2014 'PMt' 04:29:15 PM with the "'PMt'" unexpected and not there in 2.9.5 under Mountain Lion.

No being very good at Objective C, I have not debugged this any further.


If I can figure out how to submit a bug report, then that will be next.


Ralph Pass
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-03-25 21:54:02 UTC
Permalink
On Tue, 25 Mar 2014 16:34:36 -0400 Ralph Pass wrote:

RP> I am running on a Mac, Mavericks, wxWidgets 3.0.0.
RP>
RP> I modify the sample program drawing to add:
RP>
RP> wxDateTime t = wxDateTime::Now();
RP> wxString timeText = t.Format();
RP>
RP> before the last DrawText call in the DrawText method and then change the last DrawText call to be:
RP>
RP> dc.DrawText("And\nmore\ntext on\nmultiple\nlines\n\n" + timeText, 110, y);
RP>
RP>
RP> The text that is displayed is: Tuesday, March 25, 2014 'PMt' 04:29:15 PM with the "'PMt'" unexpected and not there in 2.9.5 under Mountain Lion.
RP>
RP> No being very good at Objective C, I have not debugged this any further.

There is no Objective C code involved here. Please do at least check what
does timeText return in order to understand if the problem is really in
wxDateTime::Format() or in wxDC::DrawText(). And if it's in Format(), it'd
be great if you could trace inside it and see what's going on there, in
particular which format string is being used.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Ralph Pass
2014-03-26 12:46:36 UTC
Permalink
The call is to wxDateTime::Format() which uses wxDefaultDateTimeFormat as its default value for its first parameter.

wxDefaultDateTimeFormat is the string %c

in datetimefmt.cpp, the %c is replaced by wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT)

Inside GetInfo is the logic

wxCFRef<CFDateFormatterRef> dateFormatter( CFDateFormatterCreate
(NULL, userLocaleRef, dateStyle, timeStyle));
wxCFStringRef cfs = wxCFRetain( CFDateFormatterGetFormat(dateFormatter ));

where cfs is the string EEEE, MMMM d, y 'at' h:mm:ss a

It looks as if the intent is to have Day of week, month day, year at hour:minute:second AM or PM

However in the translation of the cfs string to a wxDateTime format string the cfs string gets replaced by:

%A, %B %d, %Y '%pt' %I:%M:%S %p

and in the logic to parse the cfs string, the 'at' is parsed to the string '%pt', that is it is not recognizing that the first ' is a delimiter for an explicit, not to be converted string. This happens in

static wxString TranslateFromUnicodeFormat(const wxString& fmt)

in the file intl.cpp. This routine does not handle a ' in a input string to be Translated.


Ralph Pass
Post by Vadim Zeitlin
RP> I am running on a Mac, Mavericks, wxWidgets 3.0.0.
RP>
RP>
RP> wxDateTime t = wxDateTime::Now();
RP> wxString timeText = t.Format();
RP>
RP>
RP> dc.DrawText("And\nmore\ntext on\nmultiple\nlines\n\n" + timeText, 110, y);
RP>
RP>
RP> The text that is displayed is: Tuesday, March 25, 2014 'PMt' 04:29:15 PM with the "'PMt'" unexpected and not there in 2.9.5 under Mountain Lion.
RP>
RP> No being very good at Objective C, I have not debugged this any further.
There is no Objective C code involved here. Please do at least check what
does timeText return in order to understand if the problem is really in
wxDateTime::Format() or in wxDC::DrawText(). And if it's in Format(), it'd
be great if you could trace inside it and see what's going on there, in
particular which format string is being used.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...