From cf14b66ff7e4ecb7b4cfaf93cd704e612f38c6a0 Mon Sep 17 00:00:00 2001 From: Nicholas Jackson Date: Fri, 9 May 2025 18:03:58 -0700 Subject: [PATCH] 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. --- flag_timestamp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flag_timestamp.go b/flag_timestamp.go index f442951929..413a2f0e48 100644 --- a/flag_timestamp.go +++ b/flag_timestamp.go @@ -86,7 +86,7 @@ func (t *timestampValue) Set(value string) error { defaultTS, _ := time.ParseInLocation(time.TimeOnly, time.TimeOnly, timestamp.Location()) - n := time.Now() + n := time.Now().In(timestamp.Location()) // If format is missing date (or year only), set it explicitly to current if timestamp.Truncate(time.Hour*24).UnixNano() == defaultTS.Truncate(time.Hour*24).UnixNano() {