mirror-cockpit-project-cockpit/pkg
Adam Williamson 61f19b06ec lib/packagekit: handle timeSpec with short offset and T
ISO 8601 allows the offset to be just two digits, e.g.:
2026-01-29T12:57:49.112827-08
the `-08` is equivalent to `-08:00`. However, ECMAscript spec
does not require parsers to handle this form, it only requires
parsing of 'Z' or '-NN:NN' or '+NN:NN' form:
https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-time-string-format

Both Firefox and Chrome Javascript parsers fail to handle
date+time strings that use T to separate the date and time
*and* use the short offset format:
https://bugzilla.mozilla.org/show_bug.cgi?id=2013444
https://issues.chromium.org/issues/479862357

PackageKit since 1.3.2, with
https://github.com/PackageKit/PackageKit/commit/8377d48 , will
produce transactions with a timespec with the T separator and the
short offset. This is because it now uses
g_date_time_format_iso8601 , which formats the offset with
`"%:::z"`:
44bce2fd71/glib/gdatetime.c (L3867)
That's documented earlier in the file as:
"the time zone as an offset from UTC, with `:` to necessary
precision (e.g., `-04`, `+05:30`)."
Before 1.3.2, PackageKit used g_time_val_to_iso8601 , which always
gives a string that ends in Z (i.e. is for UTC time).

So to work around the browsers' inability to parse this specific
form, let's spot it with a regex and append ':00' if the regex
matches. We don't bother checking for the T separator, but it's
harmless to add the :00 if the string uses a space, so it's fine.

Note ISO 8601 also allows e.g. `-0800` (no :), but I don't think
PK can produce that form currently, and Firefox's and Chromium's
parsers both handle it anyway.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
Co-Authored-By: Martin Pitt <mpitt@redhat.com>
2026-02-04 10:26:00 +01:00
..
apps pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
base1 pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
kdump pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
lib lib/packagekit: handle timeSpec with short offset and T 2026-02-04 10:26:00 +01:00
metrics pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
networkmanager pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
packagekit packagekit: handle empty history after successful update 2026-02-04 10:26:00 +01:00
playground pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
selinux REUSE: Convert license headers to SPDX format 2026-02-04 10:24:11 +01:00
shell pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
sosreport pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
static pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
storaged pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
systemd pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
users pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
Makefile.am pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00
ruff.toml pkg: Add missing license declarations 2026-02-04 10:24:11 +01:00