The OpenD Programming Language

Timestamp.this

Creates a fake timestamp from a Duration using total!"hnsecs" method. For positive and zero timestamps the format is wwww-dd-88Thh:mm:ss.nnnnnnn and for negative timestamps wwww-dd-99Thh:mm:ss.nnnnnnn.

Examples

import core.time : Duration, weeks, days, hours, minutes, seconds, hnsecs;

auto duration = 5.weeks + 2.days + 7.hours + 40.minutes + 4.seconds + 9876543.hnsecs;
Timestamp ts = duration;

assert(ts.toISOExtString == `0005-02-88T07:40:04.9876543-00:00`);
assert(duration == cast(Duration) ts);

duration = -duration;
ts = Timestamp(duration);
assert(ts.toISOExtString == `0005-02-99T07:40:04.9876543-00:00`);
assert(duration == cast(Duration) ts);

assert(Timestamp(Duration.zero).toISOExtString == `0000-00-88T00:00:00.0000000-00:00`);

Meta