Closed reitermarkus closed 1 year ago
You can just subtract them. Though that will be inaccurate in that it misses all the leap seconds between the two date times. I have a branch that takes leap seconds into account, but that's probably a separate issue to discuss.
Yeah, subtracting them does the trick.
Leap seconds are a completely different story, and that won't be supported until the tzdb is integrated. That's something I have not done any actual work on, only some thinking about how I want the API to look.
Yeah, subtracting them does the trick.
That's what I tried, but I see my problem. It does not work in const
context, e.g.
const GPS_EPOCH: OffsetDateTime = datetime!(1980-01-06 00:00 UTC);
const GPS_TO_UNIX_TIME_OFFSET: time::Duration = OffsetDateTime::UNIX_EPOCH - GPS_EPOCH;
I have a branch that takes leap seconds into account, but that's probably a separate issue to discuss.
This would probably also be beneficial for my use case.
That's because trait implementations cannot currently be const. Once they can, it is almost certain that I will constify that and many others. It doesn't mean that the trait isn't currently implemented.
Yeah, the error message is actually quite clear after reading it the second time:
the trait `Sub<_>` is implemented for `OffsetDateTime`, but that implementation is not `const`
That's actually a significant improvement than it was last time I was playing around with const traits on nightly. It used to be far more confusing.
Currently it seems that only
Instant::elapsed
provides a way to get aDuration
, but there is no way to get aDuration
between twoOffsetDateTime
s.