@@ -1193,7 +1193,7 @@ var rfc3339TimestampRegex = regexp.MustCompile(
11931193// timeStringTimestampRegex matches time.String-style timestamps embedded in
11941194// CLI output.
11951195var timeStringTimestampRegex = regexp .MustCompile (
1196- `\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [+-]\d{4} [A-Z]{2,5}` ,
1196+ `\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [+-]\d{4} (?: [A-Z]{2,5}|[+-]\d{2}(?:\d{2})?) ` ,
11971197)
11981198
11991199// normalizeTimestamps rewrites embedded timestamps to UTC to avoid
@@ -1214,7 +1214,14 @@ func normalizeTimestamps(text string) string {
12141214
12151215 // Normalize time.String timestamps next.
12161216 timeReplacer := func (ts string ) string {
1217- parsed , err := time .Parse ("2006-01-02 15:04:05 -0700 MST" , ts )
1217+ zoneNameIndex := strings .LastIndex (ts , " " )
1218+ if zoneNameIndex <= 0 {
1219+ return ts
1220+ }
1221+
1222+ parsed , err := time .Parse (
1223+ "2006-01-02 15:04:05 -0700" , ts [:zoneNameIndex ],
1224+ )
12181225 if err != nil {
12191226 return ts
12201227 }
@@ -1229,6 +1236,41 @@ func normalizeTimestamps(text string) string {
12291236 return text
12301237}
12311238
1239+ // TestNormalizeTimestamps verifies that timestamp normalization handles the
1240+ // timestamp formats emitted by CLI commands in different local time zones.
1241+ func TestNormalizeTimestamps (t * testing.T ) {
1242+ t .Parallel ()
1243+
1244+ testCases := []struct {
1245+ name string
1246+ text string
1247+ want string
1248+ }{
1249+ {
1250+ name : "rfc3339" ,
1251+ text : "updated: 2026-01-26T01:28:06-05:00\n " ,
1252+ want : "updated: 2026-01-26T06:28:06Z\n " ,
1253+ },
1254+ {
1255+ name : "alphabetic time string zone" ,
1256+ text : "deadline: 2026-01-26 01:28:06 -0500 EST\n " ,
1257+ want : "deadline: 2026-01-26 06:28:06 +0000 UTC\n " ,
1258+ },
1259+ {
1260+ name : "numeric time string zone" ,
1261+ text : "deadline: 2026-01-26 03:28:06 -0300 -03\n " ,
1262+ want : "deadline: 2026-01-26 06:28:06 +0000 UTC\n " ,
1263+ },
1264+ }
1265+
1266+ for _ , testCase := range testCases {
1267+ t .Run (testCase .name , func (t * testing.T ) {
1268+ got := normalizeTimestamps (testCase .text )
1269+ require .Equal (t , testCase .want , got )
1270+ })
1271+ }
1272+ }
1273+
12321274// TestCloneCommandForReplayResetsFlagState verifies cloned commands reset flag
12331275// state.
12341276func TestCloneCommandForReplayResetsFlagState (t * testing.T ) {
0 commit comments