Skip to content

Commit cf14b66

Browse files
committed
fix: off-by-one in timestamp parsing
Timestamps without dates would infer the correct date based on the local time. This can lead to bugs where the current local date is different than the date in the timezone of the original value. Fix this by using time.Now().In() to adjust the timezone.
1 parent ac40eb5 commit cf14b66

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flag_timestamp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (t *timestampValue) Set(value string) error {
8686

8787
defaultTS, _ := time.ParseInLocation(time.TimeOnly, time.TimeOnly, timestamp.Location())
8888

89-
n := time.Now()
89+
n := time.Now().In(timestamp.Location())
9090

9191
// If format is missing date (or year only), set it explicitly to current
9292
if timestamp.Truncate(time.Hour*24).UnixNano() == defaultTS.Truncate(time.Hour*24).UnixNano() {

0 commit comments

Comments
 (0)