Times in UTC everywhere, and every day stored as YYYY-MM-DD #313

Closed
opened 2026-11-11 00:57:22 +01:00 by clawbot · 1 comment
Collaborator

sneak, on #217:

a day should never be stored as a timestamp but as a YYYY-MM-DD always, it's pathological to use a timestamp for a day

"invalid states should be made impossible to represent" - storing a date as a timestamp makes it ambiguous what is correct, and you also introduce time zone ambiguity.

also document somewhere that everything always everywhere in this application stores everything and logs everything and handles everything in utc regardless of TZ or the system time.

Reading: #217 (comment).

Definition of done, one PR into next:

  • Days: every day the program stores, logs or compares is a YYYY-MM-DD value, in a type that can hold nothing else, never a time.Time. Known case: AbuseIPDB's daily count stores its day as time.Time in internal/reputation/abuseipdb.go. Find every other case and list them in the PR body.
  • UTC: every time the program stores, logs, prints or compares is in UTC, whatever TZ or the system clock's zone. A test runs with TZ set to a zone far from UTC and shows a stored state file, a request log line and a process log line all in UTC.
  • Document it in one place a newcomer reads: SPEC.md, near the start, one short paragraph saying that the whole application stores, logs and handles every time in UTC, and every day as YYYY-MM-DD; AGENTS.md names it as an iron rule.
  • No other behaviour changes. Before 1.0 there is no installed base, so the state file format changes in place, with no migration.

Follow AGENTS.md: checks only through make targets. make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. Push over SSH and post with tea, since GITEA_TOKEN is refused. Label the PR needs-review.

Model: opus-5-5

sneak, on https://git.eeqj.de/sneak/smallwebwaf/issues/217: > a day should never be stored as a timestamp but as a YYYY-MM-DD always, it's pathological to use a timestamp for a day > "invalid states should be made impossible to represent" - storing a date as a timestamp makes it ambiguous what is correct, and you also introduce time zone ambiguity. > > also document somewhere that everything always everywhere in this application stores everything and logs everything and handles everything in utc regardless of TZ or the system time. Reading: https://git.eeqj.de/sneak/smallwebwaf/issues/217#issuecomment-176005. **Definition of done**, one PR into `next`: - **Days:** every day the program stores, logs or compares is a `YYYY-MM-DD` value, in a type that can hold nothing else, never a `time.Time`. Known case: AbuseIPDB's daily count stores its day as `time.Time` in `internal/reputation/abuseipdb.go`. Find every other case and list them in the PR body. - **UTC:** every time the program stores, logs, prints or compares is in UTC, whatever `TZ` or the system clock's zone. A test runs with `TZ` set to a zone far from UTC and shows a stored state file, a request log line and a process log line all in UTC. - **Document it** in one place a newcomer reads: `SPEC.md`, near the start, one short paragraph saying that the whole application stores, logs and handles every time in UTC, and every day as `YYYY-MM-DD`; `AGENTS.md` names it as an iron rule. - No other behaviour changes. Before 1.0 there is no installed base, so the state file format changes in place, with no migration. Follow `AGENTS.md`: checks only through `make` targets. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. Push over SSH and post with `tea`, since `GITEA_TOKEN` is refused. Label the PR `needs-review`. Model: opus-5-5
clawbot self-assigned this 2026-11-11 00:57:22 +01:00
Author
Collaborator

Built in #317.

  • AbuseIPDB's day in reputation.json is now a date, "day": "2026-10-06", kept as a civil.Date from the UTC clock. It was the only day the program stored or compared.
  • Times were already UTC. A new test runs sww discriminator with TZ 14 hours ahead of UTC and checks that the process line, the request line and clients.json are in UTC.
  • SPEC.md states the rule near its start; AGENTS.md makes it an iron rule.
  • Judgement call, open for the owner: a time an admin writes into a state file with an offset keeps that offset when sww writes the file back. Converting such times on load touches about 25 fields in 8 packages.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/317. - AbuseIPDB's day in `reputation.json` is now a date, `"day": "2026-10-06"`, kept as a `civil.Date` from the UTC clock. It was the only day the program stored or compared. - Times were already UTC. A new test runs `sww discriminator` with `TZ` 14 hours ahead of UTC and checks that the process line, the request line and `clients.json` are in UTC. - `SPEC.md` states the rule near its start; `AGENTS.md` makes it an iron rule. - Judgement call, open for the owner: a time an admin writes into a state file with an offset keeps that offset when sww writes the file back. Converting such times on load touches about 25 fields in 8 packages. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#313