Details
-
Type:
Bug
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: daf_base
-
Labels:
-
Story Points:2
-
Epic Link:
-
Sprint:Alert Production F16 - 9
-
Team:Alert Production
Description
The following fails for reasons I do not understand:
from lsst.daf.base import DateTime
|
# for most versions of daf_base
|
DateTime("1969-12-31T23:59:59Z")
|
# if using the latest master of daf_base
|
DateTime("1969-12-31T23:59:59Z", DateTime.UTC)
|
The error is:
File "src/DateTime.cc", line 391, in lsst::daf::base::DateTime::DateTime(int, int, int, int, int, int, lsst::daf::base::DateTime::Timescale)
|
Unconvertible date: 1969-12-31T23:59:59 {0}
|
lsst::pex::exceptions::DomainError: 'Unconvertible date: 1969-12-31T23:59:59'
|
and comes from this code:
dafBase::DateTime::DateTime(int year, int month, int day,
|
int hr, int min, int sec, Timescale scale) {
|
|
|
struct tm tm;
|
tm.tm_year = year - 1900;
|
tm.tm_mon = month - 1;
|
tm.tm_mday = day;
|
tm.tm_hour = hr;
|
tm.tm_min = min;
|
tm.tm_sec = sec;
|
tm.tm_wday = 0;
|
tm.tm_yday = 0;
|
tm.tm_isdst = 0;
|
tm.tm_gmtoff = 0;
|
|
time_t secs = timegm(&tm);
|
|
// long long nsecs will blow out beyond sep 21, 1677 0:00:00, and apr 12 2262 00:00:00
|
// (refering to the values of EPOCH_IN_MJD +/- MAX_DAYS ... exceeds 64 bits.)
|
// However, a tm struct is only 32 bits, and saturates at:
|
// low end - Dec 13 1901, 20:45:52
|
// hi end - Jan 19 2038, 03:14:07
|
|
if (secs == -1) {
|
throw LSST_EXCEPT(
|
lsst::pex::exceptions::DomainError,
|
(boost::format("Unconvertible date: %04d-%02d-%02dT%02d:%02d:%02d")
|
% year % month % day % hr % min % sec).str());
|
}
|
A mutex would only work if we can guarantee that this is the only code in the entire system that uses the TZ environment variable or the tzname global variable, which seems difficult. See also http://www.catb.org/esr/time-programming/#_good_programming_practice. All of this is moot once we integrate with astropy.time.