return ostr;
}
+WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxDateTime::wxDateTime_t)
+
// to test Today() meaningfully we must be able to change the system date which
// is not usually the case, but if we're under Win32 we can try it -- define
// the macro below to do it
// JDNs must be computed for UTC times
double jdn = dt.FromUTC().GetJulianDayNumber();
- CPPUNIT_ASSERT( jdn == d.jdn );
+ CPPUNIT_ASSERT_EQUAL( d.jdn, jdn );
dt.Set(jdn);
- CPPUNIT_ASSERT( dt.GetJulianDayNumber() == jdn );
+ CPPUNIT_ASSERT_EQUAL( jdn, dt.GetJulianDayNumber() );
}
}
void DateTimeTestCase::TestTimeDST()
{
// taken from http://www.energy.ca.gov/daylightsaving.html
- static const Date datesDST[2][2004 - 1900 + 1] =
+ static const Date datesDST[2][2009 - 1990 + 1] =
{
{
{ 1, wxDateTime::Apr, 1990, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 7, wxDateTime::Apr, 2002, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 6, wxDateTime::Apr, 2003, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 4, wxDateTime::Apr, 2004, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 3, wxDateTime::Apr, 2005, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 2, wxDateTime::Apr, 2006, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ {11, wxDateTime::Mar, 2007, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 9, wxDateTime::Mar, 2008, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 8, wxDateTime::Mar, 2009, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
},
{
{ 28, wxDateTime::Oct, 1990, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 27, wxDateTime::Oct, 2002, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 26, wxDateTime::Oct, 2003, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
{ 31, wxDateTime::Oct, 2004, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 30, wxDateTime::Oct, 2005, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 29, wxDateTime::Oct, 2006, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 4, wxDateTime::Nov, 2007, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 2, wxDateTime::Nov, 2008, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+ { 1, wxDateTime::Nov, 2009, 0, 0, 0, 0.0, wxDateTime::Inv_WeekDay, 0 },
+
}
};
- for ( int year = 1990; year < 2005; year++ )
+ for ( size_t n = 0; n < WXSIZEOF(datesDST[0]); n++ )
{
+ const int year = 1990 + n;
wxDateTime dtBegin = wxDateTime::GetBeginDST(year, wxDateTime::USA),
dtEnd = wxDateTime::GetEndDST(year, wxDateTime::USA);
- size_t n = year - 1990;
const Date& dBegin = datesDST[0][n];
const Date& dEnd = datesDST[1][n];
- CPPUNIT_ASSERT( dBegin.SameDay(dtBegin.GetTm()) );
- CPPUNIT_ASSERT( dEnd.SameDay(dtEnd.GetTm()) );
+ CPPUNIT_ASSERT_EQUAL( dBegin.DT().FormatDate(), dtBegin.FormatDate() );
+ CPPUNIT_ASSERT_EQUAL( dEnd.DT().FormatDate(), dtEnd.FormatDate() );
}
}
const char *result = dt2.ParseFormat(s, fmt);
if ( !result )
{
- // converion failed - should it have?
+ // conversion failed - should it have?
CPPUNIT_ASSERT( kind == CompareNone );
}
else // conversion succeeded
}
}
+ wxDateTime dt;
+
+ // test partially specified dates too
+ wxDateTime dtDef(26, wxDateTime::Sep, 2008);
+ CPPUNIT_ASSERT( dt.ParseFormat("17", "%d") );
+ CPPUNIT_ASSERT_EQUAL( 17, dt.GetDay() );
+
// test compilation of some calls which should compile (and not result in
// ambiguity because of char*<->wxCStrData<->wxString conversions)
- wxDateTime dt;
wxString s("foo");
CPPUNIT_ASSERT( !dt.ParseFormat("foo") );
CPPUNIT_ASSERT( !dt.ParseFormat(wxT("foo")) );
{ 219, 0, 0, 0, "%H", "219" },
{ 219, 0, 0, 0, "%D, %H", "9, 03" },
{ 219, 0, 0, 0, "%E, %D, %H", "1, 2, 03" },
+ { 0, -1, 0, 0, "%H:%M:%S", "-00:01:00" },
+ { 0, 0, -1, 0, "%H:%M:%S", "-00:00:01" },
};
for ( size_t n = 0; n < WXSIZEOF(testSpans); n++ )
{
const TimeSpanFormatTestData& td = testSpans[n];
wxTimeSpan ts(td.h, td.min, td.sec, td.msec);
- CPPUNIT_ASSERT_EQUAL( wxString(td.result), ts.Format(td.fmt) );
+ CPPUNIT_ASSERT_EQUAL( td.result, ts.Format(td.fmt) );
}
}
for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
{
- wxDateTime dt;
if ( dt.ParseDate(parseTestDates[n].str) )
{
CPPUNIT_ASSERT( parseTestDates[n].good );
wxDateTime dt;
for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
{
- wxDateTime dt;
if ( dt.ParseDateTime(parseTestDates[n].str) )
{
CPPUNIT_ASSERT( parseTestDates[n].good );