wxString Format() const
{
wxString s;
- s.Printf(_T("%02d:%02d:%02d %10s %02d, %4d%s"),
+ s.Printf(wxT("%02d:%02d:%02d %10s %02d, %4d%s"),
hour, min, sec,
wxDateTime::GetMonthName(month).c_str(),
day,
abs(wxDateTime::ConvertYearToBC(year)),
- year > 0 ? _T("AD") : _T("BC"));
+ year > 0 ? wxT("AD") : wxT("BC"));
return s;
}
wxString FormatDate() const
{
wxString s;
- s.Printf(_T("%02d-%s-%4d%s"),
+ s.Printf(wxT("%02d-%s-%4d%s"),
day,
wxDateTime::GetMonthName(month, wxDateTime::Name_Abbr).c_str(),
abs(wxDateTime::ConvertYearToBC(year)),
- year > 0 ? _T("AD") : _T("BC"));
+ year > 0 ? wxT("AD") : wxT("BC"));
return s;
}
};
wxString s, which;
switch ( nWeek < -1 ? -nWeek : nWeek )
{
- case 1: which = _T("first"); break;
- case 2: which = _T("second"); break;
- case 3: which = _T("third"); break;
- case 4: which = _T("fourth"); break;
- case 5: which = _T("fifth"); break;
+ case 1: which = wxT("first"); break;
+ case 2: which = wxT("second"); break;
+ case 3: which = wxT("third"); break;
+ case 4: which = wxT("fourth"); break;
+ case 5: which = wxT("fifth"); break;
- case -1: which = _T("last"); break;
+ case -1: which = wxT("last"); break;
}
if ( nWeek < -1 )
{
- which += _T(" from end");
+ which += wxT(" from end");
}
- s.Printf(_T("The %s %s of %s in %d"),
+ s.Printf(wxT("The %s %s of %s in %d"),
which.c_str(),
wxDateTime::GetWeekDayName(wday).c_str(),
wxDateTime::GetMonthName(month).c_str(),
{ { 16, wxDateTime::Oct, 1942, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 }, 42, 3, 3, 289 },
{ { 30, wxDateTime::Dec, 2003, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 }, 1, 5, 5, 364 },
{ { 2, wxDateTime::Jan, 2004, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 }, 1, 1, 1, 2 },
+ { { 5, wxDateTime::Jan, 2010, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 }, 1, 2, 2, 5 },
+ { { 3, wxDateTime::Jan, 2011, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 }, 1, 2, 2, 3 },
};
for ( size_t n = 0; n < WXSIZEOF(weekNumberTestDates); n++ )
wmon2 = dt.GetWeekOfMonth(wxDateTime::Sunday_First),
dnum = dt.GetDayOfYear();
- CPPUNIT_ASSERT_EQUAL( wn.dnum, dnum );
- CPPUNIT_ASSERT_EQUAL( wn.wmon, wmon );
- CPPUNIT_ASSERT_EQUAL( wn.wmon2, wmon2 );
- CPPUNIT_ASSERT_EQUAL( wn.week, week );
+ WX_ASSERT_EQUAL_MESSAGE( ("day of year for %s", d.Format()),
+ wn.dnum, dnum );
+ WX_ASSERT_EQUAL_MESSAGE( ("week of month (Monday) for %s", d.Format()),
+ wn.wmon, wmon );
+ WX_ASSERT_EQUAL_MESSAGE( ("week of month (Sunday) for %s", d.Format()),
+ wn.wmon2, wmon2 );
+ WX_ASSERT_EQUAL_MESSAGE( ("week of year for %s", d.Format()),
+ wn.week, week );
int year = d.year;
if ( week == 1 && d.month != wxDateTime::Jan )
break;
case CompareNone:
- wxFAIL_MSG( _T("unexpected") );
+ wxFAIL_MSG( wxT("unexpected") );
break;
}
}
// special cases
wxDateTime dt;
- CPPUNIT_ASSERT( dt.ParseDate(_T("today")) );
+ CPPUNIT_ASSERT( dt.ParseDate(wxT("today")) );
CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), dt );
for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
bool good;
} parseTestDates[] =
{
- { "Thu 22 Nov 2007 07:40:00 PM",
- { 22, wxDateTime::Nov, 2007, 19, 40, 0}, true },
+ {
+ "Thu 22 Nov 2007 07:40:00 PM",
+ { 22, wxDateTime::Nov, 2007, 19, 40, 0 },
+ true
+ },
+
+ {
+ "2010-01-04 14:30",
+ { 4, wxDateTime::Jan, 2010, 14, 30, 0 },
+ true
+ },
+
+ {
+ "bloordyblop",
+ { 1, wxDateTime::Jan, 9999, 0, 0, 0},
+ false
+ },
};
// the test strings here use "PM" which is not available in all locales so