Skip to content

Commit 25d3152

Browse files
committed
fix(assert): normalize Z suffix to +0000 for date parsing
1 parent a122c56 commit 25d3152

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/assert_dates.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ function bashunit::date::to_epoch() {
1212
;;
1313
esac
1414

15-
# Normalize ISO 8601: replace T with space, strip Z suffix, strip tz offset
15+
# Normalize Z suffix to +0000 (understood by both GNU and BSD date)
16+
case "$input" in
17+
*Z)
18+
input="${input%Z}+0000"
19+
;;
20+
esac
21+
22+
# Normalize ISO 8601: replace T with space, strip tz offset
1623
local normalized="$input"
1724
normalized="${normalized/T/ }"
18-
normalized="${normalized%Z}"
1925
# Strip timezone offset (+HHMM or -HHMM) at end for initial parsing
2026
case "$normalized" in
2127
*[+-][0-9][0-9][0-9][0-9])

0 commit comments

Comments
 (0)