diff --git a/Foundation/include/Poco/DateTime.h b/Foundation/include/Poco/DateTime.h index a50577031..5357a4ee3 100644 --- a/Foundation/include/Poco/DateTime.h +++ b/Foundation/include/Poco/DateTime.h @@ -427,6 +427,16 @@ inline void swap(DateTime& d1, DateTime& d2) } +inline void DateTime::checkLimit(short& lower, short& higher, short limit) +{ + if (lower >= limit) + { + higher += short(lower / limit); + lower = short(lower % limit); + } +} + + } // namespace Poco diff --git a/Foundation/src/DateTime.cpp b/Foundation/src/DateTime.cpp index 884d3f8c2..b5bc9e3e3 100644 --- a/Foundation/src/DateTime.cpp +++ b/Foundation/src/DateTime.cpp @@ -335,23 +335,13 @@ double DateTime::toJulianDay(int year, int month, int day, int hour, int minute, } -void DateTime::checkLimit(short& lower, short& higher, short limit) -{ - if (lower > limit) - { - higher += short(lower / limit); - lower = short((lower % limit) - 1); - } -} - - void DateTime::normalize() { - checkLimit(_microsecond, _millisecond, 999); - checkLimit(_millisecond, _second, 999); - checkLimit(_second, _minute, 59); - checkLimit(_minute, _hour, 59); - checkLimit(_hour, _day, 23); + checkLimit(_microsecond, _millisecond, 1000); + checkLimit(_millisecond, _second, 1000); + checkLimit(_second, _minute, 60); + checkLimit(_minute, _hour, 60); + checkLimit(_hour, _day, 24); if (_day > daysOfMonth(_year, _month)) {