-
Notifications
You must be signed in to change notification settings - Fork 299
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
Add ToTimeInDefaultLocation/E #80
Conversation
62d766f
to
2e435db
Compare
2172ccb
to
69c1d41
Compare
Go's time parsing uses UTC when the format doesn't have a tiemzone, and has even weirder behavior when it has a zone name but no numeric offset. A caller to `cast.ToTime` won't know if the returned time was explicitly in UTC, or defaulted there, so the caller cannot fix it. These new functions allow a user to supply a different timezone to default to, with nil using the local zone.
0881fcb
to
dc790bf
Compare
f5b8561
to
089f9f4
Compare
This commit adjusts the previous commit re. the new `ToTimeInDefaultLocationE` and related functions. The functional change is that we don't default to any location if not provided from the caller. This is in line with how `ToTime` worked before we started this, and even if the default behaviour may look weird in some cases, it will not break anything. Most applications will want to use the new *InDefaultLocation functions and decide which default location to use: ```go loc := time.Local if config.Location != "" { loc = time.LoadLocation(config.Location) } t, err := StringToDateInDefaultLocation("2019-01-01", loc) ``` This commit also configure Travis to test on OSX and Windows in addition to Linux.
The context for this PR is described in #23 from @heewa I can just repeat here that the reason we don't use One example would be that |
This can be closed since e4dda5f. |
No description provided.