# # # patch "dates.cc" # from [adef154c11663617886e64c64766118e3ba29e8f] # to [e408c478777f809bf54b3229e561efcd21b6a2ed] # # patch "dates.hh" # from [200aa0a5b91d958ef7652aa3871e95ef6c5bc2d6] # to [fe6e8cadbc8fde206f28d011a844500a26d7c47b] # ============================================================ --- dates.cc adef154c11663617886e64c64766118e3ba29e8f +++ dates.cc e408c478777f809bf54b3229e561efcd21b6a2ed @@ -39,11 +39,8 @@ date_t::date_t(u64 d) date_t::date_t(u64 d) : d(d) { - using std::tm; - - struct tm tm; - gmtime(tm); - I(tm.tm_year + 1900 < 10000); + // year 10000 limit + I(d < u64_C(253402300800)); } date_t::date_t(int sec, int min, int hour, int day, int month, int year) @@ -165,6 +162,12 @@ date_t::as_iso_8601_extended() const % tm.tm_hour % tm.tm_min % tm.tm_sec).str(); } +u64 +date_t::as_unix_epoch() const +{ + return d; +} + void date_t::gmtime(struct tm & tm) const { @@ -235,7 +238,6 @@ date_t::gmtime(struct tm & tm) const t -= this_month; month++; - L(FL("gmtime: month >= %u, t now %llu") % month % t); I(month < 12); } ============================================================ --- dates.hh 200aa0a5b91d958ef7652aa3871e95ef6c5bc2d6 +++ dates.hh fe6e8cadbc8fde206f28d011a844500a26d7c47b @@ -39,6 +39,9 @@ struct date_t // Write out date as a string. std::string as_iso_8601_extended() const; + // Retrieve the Unix epoch timestamp itself + u64 as_unix_epoch() const; + // Date comparison operators bool operator <(struct date_t const & other) const { return d < other.d; };