-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: Parse does not detect bad days ("00" -> returns wrong date && err=nil) #17874
Comments
Working as intended. As the docs say,
|
Thanks for very swift reply, appreciated. Mentioned "31" and "99" for February does return "day out of range" error (as expected) . "00" instead overflows in the previous month with 'nil' error (unexpected) (https://play.golang.org/p/o9lQ_TBTZH) parse(...) DOES evaluate the validity of the day of the month. time.Parse("02.01.2006", "29.02.1970") -> returns "day out of range" error This "00" overflowing from "00.01.1970" into "31.12.1969" with 'nil' error appears - to me - inconsistent. |
Can I work on it? |
@lucasalcantara Feel free to send a CL |
@lucasalcantara, status? Alternatively, anybody else (including @robpike) is welcome to send a CL. |
@bradfitz sorry brad, my pc broke and will take a while to fix. So anyone can get this. I forgot to comment in here. |
I can take this on, I've got the bandwidth and I've just prepared a CL for it, about to mail it. |
Oops, the Gobot hadn't tagged this issue so I mailed a dupe CL https://go-review.googlesource.com/c/33434, @bradfitz's is ready to go, so I'll abandon mine :) |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?OARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/larsklingsten/source/golang"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qc/2q_p2_zd32g_2lz3v5w8yclw0000gn/T/go-build111275672=/tmp/go-build -gno-record-gcc-switches -fno-co
mmon"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
v, err := time.Parse("02.01.2006", "00.01.1970")
fmt.Println(v, err)
// see -> https://play.golang.org/p/FvCKKNbPK5
What did you expect to see?
0001-01-01 00:00:00 +0000 UTC
What did you see instead?
1969-12-31 00:00:00 +0000 UTC
The text was updated successfully, but these errors were encountered: