[SF 2804457] DateTime::checkLimit looks wrong

This commit is contained in:
Aleksandar Fabijanic 2009-06-15 22:23:41 +00:00
parent 5245543642
commit 29bd22fe69
2 changed files with 15 additions and 15 deletions

View File

@ -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

View File

@ -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))
{