Skip to content

Commit b7b743b

Browse files
committed
Adding test for 2014.02.13 00:00:00
1 parent 6b43995 commit b7b743b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

parseany_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,3 +759,19 @@ func TestRetryAmbiguousDateWithSwap(t *testing.T) {
759759
assert.Equal(t, nil, err)
760760
assert.Equal(t, "2014-02-13 04:08:09 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
761761
}
762+
763+
func TestDottedDateWithTime(t *testing.T) {
764+
// Taking 2014-02-13 00:00:00 as the baseline for comparison
765+
tsBaseline, err := ParseStrict("2014-02-13 00:00:00")
766+
assert.NoError(t, err)
767+
768+
// 2014.02.13 is parsed correctly and equivalent to the baseline
769+
tsShort, err := ParseStrict("2014.02.13")
770+
assert.NoError(t, err)
771+
assert.Equal(t, tsBaseline, tsShort)
772+
773+
// But 2014.02.13 00:00:00 cannot be parsed (error is "month out of range")
774+
tsLong, err := ParseStrict("2014.02.13 00:00:00")
775+
assert.NoError(t, err)
776+
assert.Equal(t, tsBaseline, tsLong)
777+
}

0 commit comments

Comments
 (0)