-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: a small bug in time abs and locabs function #24093
Labels
Comments
Thank you for your bug report. Is it possible to write a test case, or short program, that demonstrates the issue?
… On 24 Feb 2018, at 17:58, Miancai Li ***@***.***> wrote:
Please answer these questions before submitting your issue. Thanks!
437 func (t Time) abs() uint64 {
438 l := t.loc
439 // Avoid function calls when possible.
440 if l == nil || l == &localLoc {
441 l = l.get()
442 }
443 sec := t.sec + internalToUnix
444 if l != &utcLoc {
445 if l.cacheZone != nil && l.cacheStart <= sec && sec < l.cacheEnd {
446 sec += int64(l.cacheZone.offset)
447 } else {
448 _, offset, _, _, _ := l.lookup(sec)
449 sec += int64(offset)
450 }
451 }
452 return uint64(sec + (unixToInternal + internalToAbsolute))
453 }
What version of Go are you using (go version)?
all go version I have check, go 1.7, 1.8 and go 1.9
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
nothing about th env
What did you do?
code review
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
line 440, if l is nil, should not use l.get().
What did you see instead?
// abs returns the time t as an absolute time, adjusted by the zone offset.
// It is called when computing a presentation property like Month or Hour.
I suggest to be
440 if l != nil && l == &localLoc {
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@davecheney sorry, it's ok when l is nil. this feature is really confuse me. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
#Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?all go version I have check, go 1.7, 1.8 and go 1.9
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?code review, nothing about the env
What did you do?
code review
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
line 440, if l is nil, should not use l.get().
What did you see instead?
// abs returns the time t as an absolute time, adjusted by the zone offset.
// It is called when computing a presentation property like Month or Hour.
I suggest to be
The text was updated successfully, but these errors were encountered: