diff options
author | Joe Tsai <joetsai@digital-static.net> | 2022-08-21 02:52:01 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2022-08-23 18:12:45 +0000 |
commit | c94633d2f89119e0f6788db09bd3df5153243f37 (patch) | |
tree | 979cc724394cfdc74316523d287b4a2920df8226 /src/time/format_test.go | |
parent | f9cdc09497af299ef6a4d4d745aa0df4ebfdce52 (diff) | |
download | go-git-c94633d2f89119e0f6788db09bd3df5153243f37.tar.gz |
time: fix Parse for time zones
The hours, minutes, and seconds fields for time zones
should not have any plus or minus signs.
Use getnum instead of atoi since the latter implicitly
handles leading signs, while the former does not.
Fixes #54570
Change-Id: If9600170af3af999739c27d81958e3649946913a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425038
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/time/format_test.go')
-rw-r--r-- | src/time/format_test.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/time/format_test.go b/src/time/format_test.go index e8caa5e1a4..5c18ef45de 100644 --- a/src/time/format_test.go +++ b/src/time/format_test.go @@ -604,6 +604,10 @@ var parseErrorTests = []ParseErrorTest{ // issue 45391. {`"2006-01-02T15:04:05Z07:00"`, "0", `parsing time "0" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "0" as "\""`}, {RFC3339, "\"", `parsing time "\"" as "2006-01-02T15:04:05Z07:00": cannot parse "\"" as "2006"`}, + + // issue 54570 + {RFC3339, "0000-01-01T00:00:00+00:+0", `parsing time "0000-01-01T00:00:00+00:+0" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "Z07:00"`}, + {RFC3339, "0000-01-01T00:00:00+-0:00", `parsing time "0000-01-01T00:00:00+-0:00" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "Z07:00"`}, } func TestParseErrors(t *testing.T) { |