diff --git a/convert.go b/convert.go index f3c3b46..fc5b0b3 100644 --- a/convert.go +++ b/convert.go @@ -115,11 +115,15 @@ func FromString(s string) (Date, error) { // FromTime validates that a `time.Time{}` contains a date and converts it to a // `Date{}`. func FromTime(t time.Time) (Date, error) { + zone, offset := t.Zone() + + hasLocationInfo := !(t.Location() == time.UTC || (zone == "" && offset == 0)) + if t.Hour() != 0 || t.Minute() != 0 || t.Second() != 0 || t.Nanosecond() != 0 || - t.Location() != time.UTC { + hasLocationInfo { return Date{}, fmt.Errorf("timestamp contains more than just date information; %s", t.Format(time.RFC3339Nano)) }