Skip to content

Commit f1b20f2

Browse files
committed
hacky fix for displaying time in correct timezone
1 parent e4d9d0a commit f1b20f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/time/time.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// offsetRegex is a regex for matching MySQL offsets (e.g. +01:00).
27-
var offsetRegex = regexp.MustCompile(`(?m)^([+\-])(\d{2}):(\d{2})$`)
27+
var offsetRegex = regexp.MustCompile(`(?m)^([+\-])(\d{1,2}):(\d{2})$`)
2828

2929
// ConvertTimeZone converts |datetime| from one timezone to another. |fromLocation| and |toLocation| can be either
3030
// the name of a timezone (e.g. "UTC") or a MySQL-formatted timezone offset (e.g. "+01:00"). If the time was converted
@@ -107,7 +107,7 @@ func ConvertTimeToLocation(datetime time.Time, location string) (time.Time, erro
107107
// If we can't parse a timezone location string, then try to parse a MySQL location offset
108108
duration, err := MySQLOffsetToDuration(location)
109109
if err == nil {
110-
return datetime.Add(-1 * duration), nil
110+
return getCopy(datetime, time.UTC).Add(-1 * duration), nil
111111
}
112112

113113
return time.Time{}, errors.New(fmt.Sprintf("error: unable to parse timezone '%s'", location))

0 commit comments

Comments
 (0)