Skip to content

Commit 7aa7aab

Browse files
committed
made validation slightly faster
1 parent f976144 commit 7aa7aab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/time.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ func ConvertTimeZone(datetime time.Time, fromLocation string, toLocation string)
4949
}
5050

5151
func ValidTimeZone(str string) bool {
52-
_, err := time.LoadLocation(str)
53-
if err == nil {
52+
if strings.ToUpper(str) == "SYSTEM" || offsetRegex.MatchString(str) {
5453
return true
5554
}
56-
return offsetRegex.MatchString(str) || strings.ToUpper(str) == "SYSTEM"
55+
_, err := time.LoadLocation(str)
56+
return err == nil
5757
}
5858

5959
// MySQLOffsetToDuration takes in a MySQL timezone offset (e.g. "+01:00") and returns it as a time.Duration.

0 commit comments

Comments
 (0)