A run not yet started shows as started in 1969 on an instance outside UTC #35

Closed
opened 2026-10-17 12:08:42 -05:00 by jeff · 0 comments
Owner

zfj run list shows a run that has not started as having started at the end of 1969:

$ zfj run list -L 1 | cat
45	waiting	Follow a run until it finishes with run watch	test.yaml	push	main	1969-12-31T18:00:00-06:00

Forgejo fills in started and stopped with the Unix epoch for a run that has not reached them. It writes every timestamp in the instance's own time zone, though, so git.jcollie.dev's epoch arrives as 1969-12-31T18:00:00-06:00, not 1970-01-01T00:00:00Z. happened in src/cli/run.zig only recognizes the string 1970-01-01T00:00:00 (and 0001-01-01 for Go's zero time), so any instance outside UTC slips past it. The NixOS test runs Forgejo in UTC, which is why it passed there.

The same mistake shows up wherever the zero time is shown:

  • run list: the started column, both on a terminal and in the tab-separated output
  • run view: "Started 1969-12-31 18:00" in place of "Created …", and a duration printed for a run that has not stopped
  • run watch: the header line, through renderRun

Fix

Parse the timestamps with zig-datetime instead of comparing strings:

  • Treat a timestamp as not having happened when it is at or before the Unix epoch, whatever its offset. That covers Go's 0001-01-01 zero time too, in any offset.
  • Keep showing times as the instance gives them, in its own offset, as minute does now. Parsing is for the comparison only.
  • A timestamp that won't parse counts as having happened and is shown as given. A display helper is no place to fail a command.

Adding the dependency means a new entry in build.zig.zon and a regenerated build.zig.zon.nix (zon2nix --17), so the Nix build and the VM test still build offline.

Tests

  • Unit tests for happened with the epoch in Z, -06:00 and +05:30, Go's zero time in an offset, a real timestamp, and one that won't parse.
  • A renderRun test for a waiting run whose zero times are in -06:00.
  • Optionally, set a non-UTC time zone on the VM's Forgejo (TZ) so the integration test sees what a real instance sends.
`zfj run list` shows a run that has not started as having started at the end of 1969: ```console $ zfj run list -L 1 | cat 45 waiting Follow a run until it finishes with run watch test.yaml push main 1969-12-31T18:00:00-06:00 ``` Forgejo fills in `started` and `stopped` with the Unix epoch for a run that has not reached them. It writes every timestamp in the instance's own time zone, though, so git.jcollie.dev's epoch arrives as `1969-12-31T18:00:00-06:00`, not `1970-01-01T00:00:00Z`. `happened` in `src/cli/run.zig` only recognizes the string `1970-01-01T00:00:00` (and `0001-01-01` for Go's zero time), so any instance outside UTC slips past it. The NixOS test runs Forgejo in UTC, which is why it passed there. The same mistake shows up wherever the zero time is shown: - `run list`: the started column, both on a terminal and in the tab-separated output - `run view`: "Started 1969-12-31 18:00" in place of "Created …", and a duration printed for a run that has not stopped - `run watch`: the header line, through `renderRun` ## Fix Parse the timestamps with [zig-datetime](https://git.jcollie.dev/jeff/zig-datetime) instead of comparing strings: - Treat a timestamp as not having happened when it is at or before the Unix epoch, whatever its offset. That covers Go's `0001-01-01` zero time too, in any offset. - Keep showing times as the instance gives them, in its own offset, as `minute` does now. Parsing is for the comparison only. - A timestamp that won't parse counts as having happened and is shown as given. A display helper is no place to fail a command. Adding the dependency means a new entry in `build.zig.zon` and a regenerated `build.zig.zon.nix` (`zon2nix --17`), so the Nix build and the VM test still build offline. ## Tests - Unit tests for `happened` with the epoch in `Z`, `-06:00` and `+05:30`, Go's zero time in an offset, a real timestamp, and one that won't parse. - A `renderRun` test for a waiting run whose zero times are in `-06:00`. - Optionally, set a non-UTC time zone on the VM's Forgejo (`TZ`) so the integration test sees what a real instance sends.
jeff closed this issue 2026-10-17 14:11:32 -05:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jeff/zfj#35
No description provided.