aboutsummaryrefslogtreecommitdiff
path: root/src/time/format.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2022-08-21 02:36:24 -0700
committerGopher Robot <gobot@golang.org>2022-08-23 17:19:32 +0000
commit4e9183cb14bf58011389c8a8c8ccaecd3ef50451 (patch)
tree6336416880882794498ca0d0a4812b1142913d4f /src/time/format.go
parent42794f3871c35d1b3837f78f29d781b6ab1c1a64 (diff)
downloadgo-4e9183cb14bf58011389c8a8c8ccaecd3ef50451.tar.xz
time: fix Parse to ignore extra sub-nanosecond digits
This modifies the code to match the comment such that the behavior truly is identical to stdSecond case. Also, it modifies the behavior to match the documented behavior where: Fractional seconds are truncated to nanosecond precision. Fixes #54567 Updates #48685 Change-Id: Ie64549e4372ab51624c105ad8ab4cc99b9b5a0b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/425037 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Diffstat (limited to 'src/time/format.go')
-rw-r--r--src/time/format.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/time/format.go b/src/time/format.go
index 80495c0266..ed2a0a8fc6 100644
--- a/src/time/format.go
+++ b/src/time/format.go
@@ -1278,7 +1278,7 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
// Take any number of digits, even more than asked for,
// because it is what the stdSecond case would do.
i := 0
- for i < 9 && i+1 < len(value) && '0' <= value[i+1] && value[i+1] <= '9' {
+ for i+1 < len(value) && '0' <= value[i+1] && value[i+1] <= '9' {
i++
}
nsec, rangeErrString, err = parseNanoseconds(value, 1+i)