pub struct UnixEpochSeconds(/* private fields */);Expand description
The supported range of seconds for the difference between any two
values of UnixEpochDays.
This range should correspond to the first second of Year::MIN
(with a minimal offset) up through (and including) the last second
of Year::MAX (with a maximal offset). Actually computing that is
non-trivial, however, it can be computed easily enough using Unix
programs like date:
$ TZ=0 date -d 'Mon Jan 1 12:00:00 AM -9999' +'%s'
date: invalid date ‘Mon Jan 1 12:00:00 AM -9999’
$ TZ=0 date -d 'Fri Dec 31 23:59:59 9999' +'%s'
253402300799Well, almost easily enough. date apparently doesn’t support negative
years. But it does support negative timestamps:
$ TZ=0 date -d '@-377705116800'
Mon Jan 1 12:00:00 AM -9999
$ TZ=0 date -d '@253402300799'
Fri Dec 31 11:59:59 PM 9999With that said, we actually end up restricting the range a bit more
than what’s above. Namely, what’s above is what we support for civil
datetimes. Because of time zones, we need to choose whether all
Timestamp values can be infallibly converted to civil::DateTime
values, or whether all civil::DateTime values can be infallibly
converted to Timestamp values. Jiff choses the former because getting
a civil datetime is important for formatting. If Jiff didn’t choose the
former, there would be some timestamps that could not be formatted.
Thus, we make room by shrinking the range of allowed instants by
precisely the maximum supported time zone offset.