Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: support for parsing variable time zones #25570

Closed
subtlepseudonym opened this issue May 25, 2018 · 4 comments
Closed

time: support for parsing variable time zones #25570

subtlepseudonym opened this issue May 25, 2018 · 4 comments

Comments

@subtlepseudonym
Copy link

@subtlepseudonym subtlepseudonym commented May 25, 2018

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".

https://play.golang.org/p/hF01Thqr3p6

@andybons andybons changed the title feature request: support for parsing variable time zones time: support for parsing variable time zones May 25, 2018
@andybons
Copy link
Member

@andybons andybons commented May 25, 2018

Can you give a bit more background on the problem you're trying to solve with a custom time format like that? Thank you.

@andybons andybons added this to the Unplanned milestone May 25, 2018
@subtlepseudonym
Copy link
Author

@subtlepseudonym subtlepseudonym commented May 29, 2018

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.

@agnivade
Copy link
Contributor

@agnivade agnivade commented Aug 13, 2019

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.

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 13, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Sep 13, 2019
@golang golang locked and limited conversation to collaborators Sep 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.