mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-06 00:31:10 +01:00
fixed GH #1465: Assertion violation in DateTime.cpp using ZipArchive
This commit is contained in:
parent
91f0b270a6
commit
aa9987e0bc
@ -40,7 +40,11 @@ Poco::DateTime ZipUtil::parseDateTime(const char* pVal, const Poco::UInt32 timeP
|
|||||||
int day = (date & 0x001fu); // 0000 0000 0001 1111
|
int day = (date & 0x001fu); // 0000 0000 0001 1111
|
||||||
int mon = ((date & 0x01e0u) >> 5); // 0000 0001 1110 0000
|
int mon = ((date & 0x01e0u) >> 5); // 0000 0001 1110 0000
|
||||||
int year = 1980+((date & 0xfe00u) >> 9); // 1111 1110 0000 0000
|
int year = 1980+((date & 0xfe00u) >> 9); // 1111 1110 0000 0000
|
||||||
|
|
||||||
|
if (Poco::DateTime::isValid(year, mon, day, hour, min, sec))
|
||||||
return Poco::DateTime(year, mon, day, hour, min, sec);
|
return Poco::DateTime(year, mon, day, hour, min, sec);
|
||||||
|
else
|
||||||
|
return Poco::DateTime(1970, 01, 01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,12 +54,10 @@ void ZipUtil::setDateTime(const Poco::DateTime& dt, char* pVal, const Poco::UInt
|
|||||||
Poco::UInt16 time = static_cast<Poco::UInt16>((dt.second()/2) + (dt.minute()<<5) + (dt.hour()<<11));
|
Poco::UInt16 time = static_cast<Poco::UInt16>((dt.second()/2) + (dt.minute()<<5) + (dt.hour()<<11));
|
||||||
// DATE: day 0-4, month 5-8, year (starting with 1980): 9-16
|
// DATE: day 0-4, month 5-8, year (starting with 1980): 9-16
|
||||||
int year = dt.year() - 1980;
|
int year = dt.year() - 1980;
|
||||||
if (year<0)
|
if (year < 0) year = 0;
|
||||||
year = 0;
|
|
||||||
Poco::UInt16 date = static_cast<Poco::UInt16>(dt.day() + (dt.month()<<5) + (year<<9));
|
Poco::UInt16 date = static_cast<Poco::UInt16>(dt.day() + (dt.month()<<5) + (year<<9));
|
||||||
ZipUtil::set16BitValue(time, pVal, timePos);
|
ZipUtil::set16BitValue(time, pVal, timePos);
|
||||||
ZipUtil::set16BitValue(date, pVal, datePos);
|
ZipUtil::set16BitValue(date, pVal, datePos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user