Closed KnorrFG closed 3 months ago
You'll want to construct a PrimitiveDateTime
or OffsetDateTime
, which can then be subtracted directly, yielding a Duration
.
Instant
is definitely not what you are looking for, as the primary use case there is for measuring elapsed time.
Hey, I'm in the following situation: I have Datetimes in a json file defined via single ints for each value (year, month, day, h, m, s, ms). At some point, I want to know the signed duration that lies between some of them. And I have a hard time figuring out how to do this.
It seems the only api that does this is defined in
time::ext::InstantExt
. There is no way to get this information without twostd::time::Instant
values, but I can't construct an Instant from a DateTime (neither primitive nor offset). I also can't construct an Instant from my integer values.Am I missing something, or is this really not possible?