diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-12-03 11:58:15 -0500 |
---|---|---|
committer | Michael Anthony Knyszek <mknyszek@google.com> | 2021-12-03 11:58:15 -0500 |
commit | c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589 (patch) | |
tree | f0543c1806db096c0ab766a14f05d2725e6c0791 /src/time/time.go | |
parent | 06a4b2790c5bb6530e0c4f05277b19c187134f49 (diff) | |
parent | 8faefcbfce6d2b2875ab74d81bb4e94b2e3adaf5 (diff) | |
download | go-c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589.tar.gz go-c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589.zip |
[dev.boringcrypto.go1.16] all: merge go1.16.11 into dev.boringcrypto.go1.16
Change-Id: I38f5b727d23d22238bf6886a7e33b5f72edeaa38
Diffstat (limited to 'src/time/time.go')
-rw-r--r-- | src/time/time.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/time/time.go b/src/time/time.go index 8ae62308e5..c8f8b9081a 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -1373,17 +1373,17 @@ func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) T unix := int64(abs) + (absoluteToInternal + internalToUnix) - // Look for zone offset for t, so we can adjust to UTC. - // The lookup function expects UTC, so we pass t in the + // Look for zone offset for expected time, so we can adjust to UTC. + // The lookup function expects UTC, so first we pass unix in the // hope that it will not be too close to a zone transition, // and then adjust if it is. _, offset, start, end := loc.lookup(unix) if offset != 0 { - switch utc := unix - int64(offset); { - case utc < start: - _, offset, _, _ = loc.lookup(start - 1) - case utc >= end: - _, offset, _, _ = loc.lookup(end) + utc := unix - int64(offset) + // If utc is valid for the time zone we found, then we have the right offset. + // If not, we get the correct offset by looking up utc in the location. + if utc < start || utc >= end { + _, offset, _, _ = loc.lookup(utc) } unix -= int64(offset) } |