georust / gpx

Rust read/write support for GPS Exchange Format (GPX)
https://crates.io/crates/gpx
MIT License
102 stars 46 forks source link

Cannot get the real value of Time #107

Closed petersohn closed 2 months ago

petersohn commented 2 months ago

Apparently, the only thing I can do with Time is to format it. I need the inner OffsetDateTime, for example to calculate durations. Currently the only way I can do it is to format it to a string then parse it because the underlying object is private. Is there a good reason for this?

gwbres commented 2 months ago

That would be immediate if Gpx used Hifitime to represent the local time. I might take a look at this, see how much it would cost to upgrade

petersohn commented 2 months ago

Why not just make the underlying OffsetDateTime public?

lnicola commented 2 months ago

It is, see https://docs.rs/gpx/latest/gpx/struct.Time.html#impl-From%3CTime%3E-for-OffsetDateTime.

petersohn commented 2 months ago

Oh, that works for me, thanks.

lnicola commented 2 months ago

The reason for this is to avoid exposing an implementation detail to the users, so we can change libraries more easily.