108 CPPUNIT_ASSERT_EQUAL(2012, test1.year());
109 CPPUNIT_ASSERT_EQUAL(2, test1.month());
110 CPPUNIT_ASSERT_EQUAL(29, test1.day());
111 CPPUNIT_ASSERT_EQUAL(15, test1.hour());
112 CPPUNIT_ASSERT_EQUAL(34, test1.minute());
113 CPPUNIT_ASSERT_EQUAL(20, test1.second());
114 CPPUNIT_ASSERT_EQUAL(33, test1.millisecond());
116 CPPUNIT_ASSERT_EQUAL((31 + 29), test1.dayOfYear());
117 CPPUNIT_ASSERT(test1.isLeapYear());
122 CPPUNIT_ASSERT_EQUAL(1, test2.year());
123 CPPUNIT_ASSERT_EQUAL(1, test2.month());
124 CPPUNIT_ASSERT_EQUAL(1, test2.day());
125 CPPUNIT_ASSERT_EQUAL(15, test2.hour());
126 CPPUNIT_ASSERT_EQUAL(34, test2.minute());
127 CPPUNIT_ASSERT_EQUAL(20, test2.second());
128 CPPUNIT_ASSERT_EQUAL(33, test2.millisecond());
131 const auto timeStamp =
static_cast<time_t
>(1453840331);
134 CPPUNIT_ASSERT(fabs((fromTimeStamp - fromTimeStampGmt).totalDays()) <= 1.0);
136 CPPUNIT_ASSERT_EQUAL(timeStamp, fromTimeStampGmt.toTimeStamp());
155 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"surplus parts ignored", test1,
DateTime::fromString(
"2012-02-29 15:34:20.033:12"));
159 CPPUNIT_ASSERT_EQUAL(
"2016-08-29T21:32:31.125+02:00"s, test3.first.toIsoString(test3.second));
163 CPPUNIT_ASSERT_EQUAL(2.5, test4.second.totalHours());
164 CPPUNIT_ASSERT_EQUAL(15, test4.first.second());
165 CPPUNIT_ASSERT_EQUAL(985, test4.first.millisecond());
166 CPPUNIT_ASSERT_EQUAL(77, test4.first.microsecond());
167 CPPUNIT_ASSERT_EQUAL(600, test4.first.nanosecond());
168 CPPUNIT_ASSERT_EQUAL(
"2017-08-23T19:40:15.9850776+02:30"s, test4.first.toIsoString(test4.second));
171 CPPUNIT_ASSERT_EQUAL(-2.5, test5.second.totalHours());
172 CPPUNIT_ASSERT_EQUAL(15, test5.first.second());
173 CPPUNIT_ASSERT_EQUAL(985, test5.first.millisecond());
174 CPPUNIT_ASSERT_EQUAL(77, test5.first.microsecond());
175 CPPUNIT_ASSERT_EQUAL(600, test5.first.nanosecond());
176 CPPUNIT_ASSERT_EQUAL(
"2017-08-23T19:40:15.9850776-02:30"s, test5.first.toIsoString(test5.second));
184 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"no seconds fraction (positive timezone offset, 1)",
DateTime::fromDateAndTime(1970, 1, 1, 1, 2, 3), test6.first);
185 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"no seconds fraction (positive timezone offset, 2)",
TimeSpan::fromHours(1.0), test6.second);
187 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"no seconds fraction (negative timezone offset, 1)",
DateTime::fromDateAndTime(2021, 5, 20, 23, 2, 45), test7.first);
188 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"no seconds fraction (negative timezone offset, 2)",
TimeSpan::fromHours(-4.0), test7.second);
190 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"no separators", test5.first - test5.second,
DateTime::fromIsoStringGmt(
"20170823T194015.985077682-0230"));
191 CPPUNIT_ASSERT_EQUAL_MESSAGE(
205 CPPUNIT_ASSERT_EQUAL(
"1234-05-06T07:08:09.0105005"s,
207 CPPUNIT_ASSERT_EQUAL(
"1234-05-06T07:08:09.010500"s,
209 CPPUNIT_ASSERT_EQUAL(
211 CPPUNIT_ASSERT_EQUAL(
213 CPPUNIT_ASSERT_EQUAL(
222#if defined(PLATFORM_UNIX)