-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
#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 }
454
455 // locabs is a combination of the Zone and abs methods,
456 // extracting both return values from a single zone lookup.
457 func (t Time) locabs() (name string, offset int, abs uint64) {
458 l := t.loc
459 if l == nil || l == &localLoc {
460 l = l.get()
461 }
462 // Avoid function call if we hit the local time cache.
463 sec := t.unixSec()
464 if l != &utcLoc {
465 if l.cacheZone != nil && l.cacheStart <= sec && sec < l.cacheEnd {
466 name = l.cacheZone.name
467 offset = l.cacheZone.offset
468 } else {
469 name, offset, _, _, _ = l.lookup(sec)
470 }
471 sec += int64(offset)
472 } else {
473 name = "UTC"
474 }
475 abs = uint64(sec + (unixToInternal + internalToAbsolute))
476 return
477 }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
440 if l != nil && l == &localLoc {
...
459 if l != nil && l == &localLoc {