wxDateTime::ParseFormat and milliseconds

181 views
Skip to first unread message

Rotlaus

unread,
Jul 22, 2009, 10:39:04 AM7/22/09
to wx-users
Hi,

In March Vadim Zeitlin posted a patch to support milliseconds in
ParseFormat with %l specifier. That works most of the time, but not
when the milliseconds are zero. Example:

datetime.ParseFormat("12:23:45.123", "%H:%M:%S.%l") works, but

datetime.ParseFormat("12:23:45.000", "%H:%M:%S.%l") works not.

Ist this a bug or am i doing something wrong?

Vadim Zeitlin

unread,
Jul 22, 2009, 12:41:07 PM7/22/09
to wx-u...@googlegroups.com
On Wed, 22 Jul 2009 07:39:04 -0700 (PDT) Rotlaus <rot...@gmail.com> wrote:

R> In March Vadim Zeitlin posted a patch to support milliseconds in
R> ParseFormat with %l specifier. That works most of the time, but not
R> when the milliseconds are zero. Example:
R>
R> datetime.ParseFormat("12:23:45.123", "%H:%M:%S.%l") works, but
R>
R> datetime.ParseFormat("12:23:45.000", "%H:%M:%S.%l") works not.
R>
R> Ist this a bug or am i doing something wrong?

This would, of course, be a bug but I don't see it: the tests added by
this patch

Index: tests/datetime/datetimetest.cpp
===================================================================
--- tests/datetime/datetimetest.cpp (revision 61484)
+++ tests/datetime/datetimetest.cpp (working copy)
@@ -786,6 +786,14 @@
CPPUNIT_ASSERT_EQUAL( 1856, dt.GetYear() );
#endif

+ // also test %l separately
+ CPPUNIT_ASSERT( dt.ParseFormat("12:23:45.678", "%H:%M:%S.%l") );
+ CPPUNIT_ASSERT_EQUAL( 678, dt.GetMillisecond() );
+
+ // test special case of %l matching 0 milliseconds
+ CPPUNIT_ASSERT( dt.ParseFormat("12:23:45.000", "%H:%M:%S.%l") );
+ CPPUNIT_ASSERT_EQUAL( 0, dt.GetMillisecond() );
+
// test partially specified dates too
wxDateTime dtDef(26, wxDateTime::Sep, 2008);
CPPUNIT_ASSERT( dt.ParseFormat("17", "%d") );

pass for me. Can you reproduce your problem in this test?

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Rotlaus

unread,
Jul 23, 2009, 3:53:03 AM7/23/09
to wx-users
On Jul 22, 6:41 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> pass for me. Can you reproduce your problem in this test?

I must have done something wrong. I compiled my wxwidgets yesterday
new, because i needed unicode support. Also i updated from 2.8.9 to
2.8.10. Now my problem is gone. Sorry for the disruption.

Kind regards,

Andre
Reply all
Reply to author
Forward
0 new messages