]> Cypherpunks repositories - gostls13.git/commit
time: quote original value in errors returned by ParseDuration
authorObeyda Djeffal <djefobey@gmail.com>
Sat, 11 Apr 2020 22:21:22 +0000 (23:21 +0100)
committerIan Lance Taylor <iant@golang.org>
Tue, 14 Apr 2020 00:01:14 +0000 (00:01 +0000)
commit201cb046b745f8bb00e3d382290190c74ba7b7e1
treeeb4e97572b16f5c526e5aaea09eadccfe0b1925d
parent5a706d163d332ec3a83e38849efbaf550a9da7ab
time: quote original value in errors returned by ParseDuration

Quote original values passed as substring of ParseError.Message.
Improves the user experience of ParseDuration by making it
quote its original argument, for example:

   _, err := time.ParseDuration("for breakfast")
 will now produce an error, which when printed out is:

  time: invalid duration "for breakfast"
 instead of:

  time: invalid duration for breakfast

Adapt test cases for format.Parse and format.ParseDuration.

Fixes #38295

Change-Id: Ife322c8f3c859e1e4e8dd546d4cf0d519b4bfa81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227878
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/time/example_test.go
src/time/format.go
src/time/format_test.go
src/time/time_test.go