- case CompareYear:
- if ( dt2.GetCentury() != dt.GetCentury() )
- {
- CPPUNIT_ASSERT_EQUAL(dt.GetYear() % 100,
- dt2.GetYear() % 100);
-
- dt2.SetYear(dt.GetYear());
- }
- // fall through and compare everything
-
- case CompareBoth:
- CPPUNIT_ASSERT_EQUAL( dt, dt2 );
- break;
-
- case CompareDate:
- CPPUNIT_ASSERT( dt.IsSameDate(dt2) );
- break;
-
- case CompareTime:
- CPPUNIT_ASSERT( dt.IsSameTime(dt2) );
- break;
-
- case CompareNone:
- wxFAIL_MSG( _T("unexpected") );
- break;
+ // conversion failed - should it have?
+ WX_ASSERT_MESSAGE(
+ ("Test #%u failed: failed to parse \"%s\"", n, s),
+ kind == CompareNone
+ );
+ }
+ else // conversion succeeded
+ {
+ // currently ParseFormat() doesn't support "%Z" and so is
+ // incapable of parsing time zone part used at the end of date
+ // representations in many (but not "C") locales, compensate
+ // for it ourselves by simply consuming and ignoring it
+ while ( *result && (*result >= 'A' && *result <= 'Z') )
+ result++;
+
+ WX_ASSERT_MESSAGE(
+ ("Test #%u failed: \"%s\" was left unparsed in \"%s\"",
+ n, result, s),
+ !*result
+ );
+
+ // Without "%z" we can't recover the time zone used in the
+ // call to Format() so we need to call MakeFromTimezone()
+ // explicitly.
+ if ( !strstr(fmt, "%z") && !isLocalTz )
+ dt2.MakeFromTimezone(tz);
+
+ switch ( kind )
+ {
+ case CompareYear:
+ if ( dt2.GetCentury() != dt.GetCentury() )
+ {
+ CPPUNIT_ASSERT_EQUAL(dt.GetYear() % 100,
+ dt2.GetYear() % 100);
+
+ dt2.SetYear(dt.GetYear());
+ }
+ // fall through and compare everything
+
+ case CompareBoth:
+ CPPUNIT_ASSERT_EQUAL( dt, dt2 );
+ break;
+
+ case CompareDate:
+ CPPUNIT_ASSERT( dt.IsSameDate(dt2) );
+ break;
+
+ case CompareTime:
+ CPPUNIT_ASSERT( dt.IsSameTime(dt2) );
+ break;
+
+ case CompareNone:
+ wxFAIL_MSG( wxT("unexpected") );
+ break;
+ }