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:
parent
383c2360e2
commit
9bb104c9f4
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue