Timestamp constructor
Creates a timestamp from seconds since the Unix epoch (UTC) and a non-negative nanoseconds
fraction below one second.
The value must lie between 0001-01-01T00:00:00Z and 9999-12-31T23:59:59.999999999Z.
The constructor is const, so it checks these ranges with asserts only,
which a release build skips. A timestamp out of range is still rejected
when it is written: the write fails with an ArgumentError.
const Timestamp epochPlusHalfSecond = Timestamp(0, 500000000);
Implementation
const Timestamp(this.seconds, this.nanoseconds)
: assert(
nanoseconds >= 0,
'Timestamp nanoseconds out of range: $nanoseconds',
),
assert(
nanoseconds < 1e9,
'Timestamp nanoseconds out of range: $nanoseconds',
),
// Midnight at the beginning of 1/1/1 is the earliest supported timestamp.
assert(
seconds >= -62135596800,
'Timestamp seconds out of range: $seconds',
),
// This will break in the year 10,000.
assert(
seconds < 253402300800,
'Timestamp seconds out of range: $seconds',
);