chronotope / chrono-tz

TimeZone implementations for rust-chrono from the IANA database
Other
229 stars 55 forks source link

Breaking change 0.6.3 to 0.7 OffsetComponents not implemented for TzOffset #114

Closed kellpossible closed 1 year ago

kellpossible commented 1 year ago

I have some code that looks like:

        use chrono_tz::OffsetComponents;

        ...

        let offset = chrono::TimeZone::offset_from_utc_datetime(&my_timezone, &utc_now);
        let total_offset: chrono::Duration = offset.base_utc_offset() + offset.dst_offset();

Upon updating to 0.7, this code now breaks with:

    |
151 |         let total_offset: chrono::Duration = offset.base_utc_offset() + offset.dst_offset();
    |                                                                                ^^^^^^^^^^ method not found in `chrono_tz::timezone_impl::TzOffset`
    |
   ::: /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-tz-0.6.3/src/timezone_impl.rs:77:8
    |
77  |     fn dst_offset(&self) -> Duration;
    |        ---------- the method is available for `chrono_tz::timezone_impl::TzOffset` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
3   | use chrono_tz::timezone_impl::OffsetComponents;
    |

I can't use chrono_tz::timezone_impl::OffsetComponents because it's private.

djc commented 1 year ago

Ah, sorry about this. Would you be able to submit a PR to fix this and/or identify when/how we regressed this?

kellpossible commented 1 year ago

@djc sorry I didn't have the bandwidth to work on this at the moment, currently have chrono-tz pinned to 0.6.3

djc commented 1 year ago

So far I think this is an issue on your side, probably with a version mismatch between different chrono-tz versions? I don't think anything relevant has changed in chrono-tz.

kellpossible commented 1 year ago

Hi @djc, this indeed appears to be the issue, I have successfully to 0.8, sorry for wasting your time looking into this!

kellpossible commented 1 year ago

I wish Rust had a system for warning when crates of different versions are clashing