-
Notifications
You must be signed in to change notification settings - Fork 18k
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: add Time.IsDST() bool method #42102
Comments
Change https://golang.org/cl/264077 mentions this issue: |
For those following, perhaps this "hack" can help in the meantime. https://github.com/ace-teknologi/isdst Cannot be assured that it'll work for all |
I misunderstood the proposal when I retitled it. It doesn't really make sense for the Location to be answering a question about a Time. The Time has its own Location built in. The method should be on the Time itself: t.IsDST, not t.Location().IsDST(t). I retitled it assuming the method would be on time.Time. Otherwise, this seems fine (with the method on time.Time). |
@rsc looking at it more I think you're right wrt method being on Happy to hear other thoughts. |
Based on the discussion above, this seems like a likely accept. |
No change in consensus, so accepted. |
Change https://golang.org/cl/307210 mentions this issue: |
Change https://golang.org/cl/326789 mentions this issue: |
Only methods that modify the time take pointer receivers; IsDST does not modify it and therefore should not. For #42102 and #46688. Change-Id: I4721ef7f4d7572236ae6e4d99a459b9ffb11999e Reviewed-on: https://go-review.googlesource.com/c/go/+/326789 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
I propose to expose a method or capability to determine if, for a given
time.Location
and a giventime.Time
, whether the zone is a daylight savings time or not.At this stage, arbitrary selection of two
time.Time
within atime.Location
is required to determine if, maybe, there is a daylight savings offset being applied (see reference to golang-nuts from 2013).Rationale
zone
s that make up atime.Location
Proposed Options
Explicit function, with amendment of
time.Location
'slocation
functionAdd an
IsDST
method to thetime.Location
with atime.Time
input. ReturnisDST
for thezone
applied, amendinglocation
ontime.Location
to also returnisDST
for the requestedsec
.Current Go source
References
The text was updated successfully, but these errors were encountered: