Fix timezone offset handling in epoch conversion

The jq epoch helper was discarding timezone offsets (e.g. -08:00) and
treating local time as UTC. Now parses the offset with capture() and
applies it correctly: -08:00 adds 8h, +05:30 subtracts 5h30m.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-02-22 11:12:50 -08:00
commit 9bb104c9f4

View file

@ -18,7 +18,8 @@ api() {
}
# jq helper: convert ISO 8601 timestamp (with any tz offset) to epoch seconds
JQ_EPOCH='def epoch: sub("[.][0-9]+"; "") | sub("[+-][0-9][0-9]:[0-9][0-9]$"; "Z") | sub("ZZ$"; "Z") | fromdate;'
# jq's fromdate only handles Z, so we parse the offset and apply it manually
JQ_EPOCH='def epoch: sub("[.][0-9]+"; "") | if test("[+-][0-9]{2}:[0-9]{2}$") then capture("^(?<dt>.*)(?<sign>[+-])(?<h>[0-9]{2}):(?<m>[0-9]{2})$") | (.dt + "Z" | fromdate) as $base | ((.h | tonumber) * 3600 + (.m | tonumber) * 60) as $off | if .sign == "-" then $base + $off else $base - $off end else sub("Z$"; "") + "Z" | fromdate end;'
forgejo_up=0
if curl -sf "${FORGEJO_URL}/api/v1/version" >/dev/null 2>&1; then