Skip to content

Commit

Permalink
Adding test for 2014.02.13 00:00:00
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdacruz committed Aug 11, 2021
1 parent 6b43995 commit b7b743b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions parseany_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,3 +759,19 @@ func TestRetryAmbiguousDateWithSwap(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, "2014-02-13 04:08:09 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}

func TestDottedDateWithTime(t *testing.T) {
// Taking 2014-02-13 00:00:00 as the baseline for comparison
tsBaseline, err := ParseStrict("2014-02-13 00:00:00")
assert.NoError(t, err)

// 2014.02.13 is parsed correctly and equivalent to the baseline
tsShort, err := ParseStrict("2014.02.13")
assert.NoError(t, err)
assert.Equal(t, tsBaseline, tsShort)

// But 2014.02.13 00:00:00 cannot be parsed (error is "month out of range")
tsLong, err := ParseStrict("2014.02.13 00:00:00")
assert.NoError(t, err)
assert.Equal(t, tsBaseline, tsLong)
}

0 comments on commit b7b743b

Please sign in to comment.