2
0
mirror of https://github.com/araddon/dateparse.git synced 2026-08-19 04:48:15 +08:00

time-parse fixes

This commit is contained in:
Aaron Raddon
2018-02-27 20:05:14 -08:00
parent 7825aa09f1
commit 20cd681f46
2 changed files with 281 additions and 314 deletions

View File

@@ -106,6 +106,13 @@ func TestInLocation(t *testing.T) {
assert.Equal(t, "2006-01-02 22:04:05 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}
func TestOne(t *testing.T) {
time.Local = time.UTC
var ts time.Time
ts = MustParse("03 February 2013")
assert.Equal(t, "2013-02-03 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}
func TestParse(t *testing.T) {
// Lets ensure we are operating on UTC
@@ -632,3 +639,21 @@ func testDidPanic(datestr string) (paniced bool) {
MustParse(datestr)
return false
}
func TestPStruct(t *testing.T) {
denverLoc, err := time.LoadLocation("America/Denver")
assert.Equal(t, nil, err)
p := newParser("08.21.71", denverLoc)
p.setMonth()
assert.Equal(t, 0, p.moi)
p.setDay()
assert.Equal(t, 0, p.dayi)
p.set(-1, "not")
p.set(15, "not")
assert.Equal(t, "08.21.71", p.datestr)
assert.Equal(t, "08.21.71", string(p.format))
}