# # # patch "dates.cc" # from [c23920088753de7b4ac1dcc5aaee5102a81e7cd9] # to [adef154c11663617886e64c64766118e3ba29e8f] # ============================================================ --- dates.cc c23920088753de7b4ac1dcc5aaee5102a81e7cd9 +++ dates.cc adef154c11663617886e64c64766118e3ba29e8f @@ -82,8 +82,24 @@ date_t::now() date_t date_t::now() { + using std::time_t; using std::time; - return date_t(static_cast(time(0))); + using std::tm; + using std::gmtime; + + // This is the only place we rely on the system's time and date function + // which might operate on different epochs (i.e. 1980-01-01, as some + // Windows, old MacOS and VMS systems used). We immediately transform that + // to a struct tm representation, which is independent of the system's + // epoch. + time_t t = time(0); + struct tm b = *gmtime(&t); + + // in CE 10000, you will need to increase the size of 'buf'. + I(b.tm_year <= 9999); + + return date_t(b.tm_sec, b.tm_min, b.tm_hour, + b.tm_mday, b.tm_mon + 1, b.tm_year + 1900); } // The Unix epoch is 1970-01-01T00:00:00 (in UTC). As we cannot safely