Open doivosevic opened 1 year ago
In general, there's no fixed start date/time per timezone -- those things can change from year to year. What is the problem you are trying to solve?
I'm trying to convert old c++ code directly to rust as closely as possible to avoid regression and then later to convert to idiomatic rust. In any case, I'd like to be able to avoid having to rewrite this datetime management part of code so that it doesn't need information such as "dst offset" and "local dst start time". I understand it's year based but as I understand this boost code can read this from tzfile, is that correct?
Maybe you should go to one level lower and look directly for crates that parse tzinfo files?
ok but is providing boost equivalent tz api something chrono might want to do?
I don't think we will implement APIs that provide a DST offset or local DST start time without some kind of date/time input. I would be willing to review a PR that adds some kind of API where DateTime<chrono_tz::Tz>
provides next_offset_change()
and prev_offset_change()
methods.
I'm trying to convert some old c++ code to rust but I'm lacking some information about the timezones. For instance:
I know I can get offset from UTC if I have some datetime but I would prefer if I wouldn't have to iterate through all days of year and then hours of that day to find when does a certain DST start or end. I see c++ boost has these methods, is there a way to extract this information? From what I can see in boos code they are extracting this data from some string but I didn't find what they are parsing.
I need stuff like
dst_offset
https://github.com/dials/boost/blob/master/boost/date_time/local_time/posix_time_zone.hpp#L177 anddst_local_start_time
https://github.com/dials/boost/blob/master/boost/date_time/local_time/posix_time_zone.hpp#L152