mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
fixed GH #1456: better handle leap seconds in Poco::DateTime and Poco::LocalDateTime
This commit is contained in:
@@ -103,7 +103,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 60 (allowing leap seconds).
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ DateTime::DateTime(int year, int month, int day, int hour, int minute, int secon
|
|||||||
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
||||||
poco_assert (hour >= 0 && hour <= 23);
|
poco_assert (hour >= 0 && hour <= 23);
|
||||||
poco_assert (minute >= 0 && minute <= 59);
|
poco_assert (minute >= 0 && minute <= 59);
|
||||||
poco_assert (second >= 0 && second <= 59);
|
poco_assert (second >= 0 && second <= 60); // allow leap seconds
|
||||||
poco_assert (millisecond >= 0 && millisecond <= 999);
|
poco_assert (millisecond >= 0 && millisecond <= 999);
|
||||||
poco_assert (microsecond >= 0 && microsecond <= 999);
|
poco_assert (microsecond >= 0 && microsecond <= 999);
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ DateTime& DateTime::assign(int year, int month, int day, int hour, int minute, i
|
|||||||
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
||||||
poco_assert (hour >= 0 && hour <= 23);
|
poco_assert (hour >= 0 && hour <= 23);
|
||||||
poco_assert (minute >= 0 && minute <= 59);
|
poco_assert (minute >= 0 && minute <= 59);
|
||||||
poco_assert (second >= 0 && second <= 59);
|
poco_assert (second >= 0 && second <= 60); // allow leap seconds
|
||||||
poco_assert (millisecond >= 0 && millisecond <= 999);
|
poco_assert (millisecond >= 0 && millisecond <= 999);
|
||||||
poco_assert (microsecond >= 0 && microsecond <= 999);
|
poco_assert (microsecond >= 0 && microsecond <= 999);
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ bool DateTime::isValid(int year, int month, int day, int hour, int minute, int s
|
|||||||
(day >= 1 && day <= daysOfMonth(year, month)) &&
|
(day >= 1 && day <= daysOfMonth(year, month)) &&
|
||||||
(hour >= 0 && hour <= 23) &&
|
(hour >= 0 && hour <= 23) &&
|
||||||
(minute >= 0 && minute <= 59) &&
|
(minute >= 0 && minute <= 59) &&
|
||||||
(second >= 0 && second <= 59) &&
|
(second >= 0 && second <= 60) &&
|
||||||
(millisecond >= 0 && millisecond <= 999) &&
|
(millisecond >= 0 && millisecond <= 999) &&
|
||||||
(microsecond >= 0 && microsecond <= 999);
|
(microsecond >= 0 && microsecond <= 999);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -847,6 +847,15 @@ void DateTimeTest::testUTC()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DateTimeTest::testLeapSeconds()
|
||||||
|
{
|
||||||
|
DateTime dt1(2015, 6, 30, 23, 59, 60);
|
||||||
|
DateTime dt2(2015, 7, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
assert (dt1 == dt2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeTest::setUp()
|
void DateTimeTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -878,6 +887,7 @@ CppUnit::Test* DateTimeTest::suite()
|
|||||||
CppUnit_addTest(pSuite, DateTimeTest, testDayOfWeek);
|
CppUnit_addTest(pSuite, DateTimeTest, testDayOfWeek);
|
||||||
CppUnit_addTest(pSuite, DateTimeTest, testIncrementDecrement);
|
CppUnit_addTest(pSuite, DateTimeTest, testIncrementDecrement);
|
||||||
CppUnit_addTest(pSuite, DateTimeTest, testUTC);
|
CppUnit_addTest(pSuite, DateTimeTest, testUTC);
|
||||||
|
CppUnit_addTest(pSuite, DateTimeTest, testLeapSeconds);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
void testDayOfWeek();
|
void testDayOfWeek();
|
||||||
void testIncrementDecrement();
|
void testIncrementDecrement();
|
||||||
void testUTC();
|
void testUTC();
|
||||||
|
void testLeapSeconds();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|||||||
Reference in New Issue
Block a user