Question about parsing in other timezones
See original GitHub issueFirst of all, thanks for the great library!
I had a question about timezone behavior: When chrono detects a timezone specified in the input string, that shows up under timezoneOffset
in knownValues
, and is accounted for when the input is parsed. When no timezone is specified, chrono parses the date in the local timezone, and no timezone offset is made.
I have a use case where I would like to parse dates in another timezone that does not match the local timezone, without being specified explicitly in the input string (it’s an application setting–the use case is viewing operational metrics in a specific timezone: many users prefer UTC than their local timezone, since it’s common across all their systems). Is it possible to have chrono assume another timezone when parsing? If not, is there a suggested workaround?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
@uhoh-itsmaciek The custom
Refiner
solution worked for me.I see. That would be challenging. Chrono doesn’t have the logic for looking up DST change. You probably have to check the parsed results, adjust the timezoneOffset, and check the resulted period and account for the DST manually.