diff --git a/fs/parseduration.go b/fs/parseduration.go index 522dbae7a..3184f6e1b 100644 --- a/fs/parseduration.go +++ b/fs/parseduration.go @@ -80,7 +80,7 @@ var timeFormats = []string{ func parseDurationDates(age string, epoch time.Time) (t time.Duration, err error) { var instant time.Time for _, timeFormat := range timeFormats { - instant, err = time.Parse(timeFormat, age) + instant, err = time.ParseInLocation(timeFormat, age, time.Local) if err == nil { return epoch.Sub(instant), nil } diff --git a/fs/parseduration_test.go b/fs/parseduration_test.go index f4be5a9bc..f0efba4bd 100644 --- a/fs/parseduration_test.go +++ b/fs/parseduration_test.go @@ -42,10 +42,12 @@ func TestParseDuration(t *testing.T) { {"1x", 0, true}, {"off", time.Duration(DurationOff), false}, {"1h2m3s", time.Hour + 2*time.Minute + 3*time.Second, false}, - {"2001-02-03", now.Sub(time.Date(2001, 2, 3, 0, 0, 0, 0, time.UTC)), false}, - {"2001-02-03 10:11:12", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 0, time.UTC)), false}, - {"2001-02-03T10:11:12", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 0, time.UTC)), false}, + {"2001-02-03", now.Sub(time.Date(2001, 2, 3, 0, 0, 0, 0, time.Local)), false}, + {"2001-02-03 10:11:12", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 0, time.Local)), false}, + {"2001-08-03 10:11:12", now.Sub(time.Date(2001, 8, 3, 10, 11, 12, 0, time.Local)), false}, + {"2001-02-03T10:11:12", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 0, time.Local)), false}, {"2001-02-03T10:11:12.123Z", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 123, time.UTC)), false}, + {"2001-02-03T10:11:12.123+00:00", now.Sub(time.Date(2001, 2, 3, 10, 11, 12, 123, time.UTC)), false}, } { duration, err := parseDurationFromNow(test.in, getNow) if test.err {