Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: support for parsing variable time zones #25570
I'm running go1.10 darwin/amd64
What did you do?
I attempted to parse "0800 EST5EDT" using a custom time format "1500 MST7MDT" and only the "EST" portion of the variable timezone was recognized by time.Parse().
What did you expect to see?
A correctly parsed *time.Time type with no errors returned.
What did you see instead?
An error was returned stating that the "5EDT" portion of the variable timezone didn't match the format's "7MDT".
I'm scheduling jobs that reoccur daily, but depend upon when the day starts and ends in that timezone. So, I need both time of day and timezone info for each job. The above format would be convenient by allowing me to store both pieces of information succinctly.
Thanks for the update @subtlepseudonym. I looked into it and it seems that the general recommendation is to use country based timezone names for situations like these. For eg. "America/New_York" is the same as "EST5EDT".
With that, you can load a location and use the In method to get the time in a location. Does that work for you ? I think it's a decent solution which uses the existing tools we have at hand, without adding additional complexity.