scripts/treno: bypass timezone insanity

This commit is contained in:
Michele Guerini Rocco 2024-02-11 17:11:05 +01:00
parent 512ad2f5c1
commit e15df3b70f
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -118,18 +118,9 @@ EOF
def green($x): "\u001B[1;32m\($x)\u001B[0m";
def blue($x): "\u001B[1;34m\($x)\u001B[0m";
def parse_iso8601:
# Parse an ISO 8601 date with timezone information
capture("(?<no_tz>[^.]*)(?<frac_sec>\\.\\d+)?(?:(?:(?<tz_sgn>[-+])(?<tz_hr>\\d{2}):?(?<tz_min>\\d{2})?)|Z)$") |
(.no_tz + "Z" | fromdateiso8601)
+ ("0"+.frac_sec | tonumber)
- (.tz_sgn + "60" | tonumber)
* ((.tz_hr // "0" | tonumber) * 60 + (.tz_min // "0" | tonumber))
| todateiso8601 | strptime("%FT%TZ");
def time:
# Extracts "HH:MM" from a timestamp
parse_iso8601 | mktime | strftime("%R");
match("T([0-9]+:[0-9]+)"; null) | .captures[0].string;
def delta($stop; $start):
# Computes the time elapsed between two dates