Bug: 12-hour AM/PM time formatting error in BST (UTC+1) — PM events displayed as AM
Summary
When in BST (British Summer Time, UTC+1), ekctl displays PM event times as AM times — a consistent 12-hour offset. Events that should show as e.g. 16:00 (4 PM) are shown as 04:00 (4 AM). The dates are correct, but the times are wrong for PM events. AM events (e.g. 09:00) display correctly.
Reproduction steps
- Be in a BST timezone (
Europe/London, during summer time, UTC+1) - Have calendar events at PM times, e.g. a "Tesco delivery" at 16:00–17:00 BST on Apr 19, and a "Theo swimming lesson" at 17:00–17:30 BST on Apr 19
- Run:
ekctl list events --calendar D82CAA49-15DD-438A-AF83-7D4C23BC37CD --from 2026-04-19T00:00:00Z --to 2026-04-20T00:00:00Z - Observe the JSON output
Actual output (wrong)
{
"startDate": "2026-04-19T4:00:00+01:00",
"endDate": "2026-04-19T5:00:00+01:00",
"title": "Tesco delivery"
}
{
"startDate": "2026-04-19T5:00:00+01:00",
"endDate": "2026-04-19T5:30:00+01:00",
"title": "Theo swimming lesson"
}
Expected output
{
"startDate": "2026-04-19T16:00:00+01:00",
"endDate": "2026-04-19T17:00:00+01:00",
"title": "Tesco delivery"
}
{
"startDate": "2026-04-19T17:00:00+01:00",
"endDate": "2026-04-19T17:30:00+01:00",
"title": "Theo swimming lesson"
}
AM events are fine
"Millie swimming lesson" at 09:00 BST correctly shows as "startDate": "2026-04-19T9:00:00+01:00".
Cross-reference
Another macOS calendar CLI tool (ical by BRO3886) returns the correct UTC times for these same events via EventKit: "start_date":"2026-04-19T15:00:00Z" for Tesco (= 16:00 BST) and "start_date":"2026-04-19T16:00:00Z" for Theo swimming (= 17:00 BST). So the underlying EventKit data is correct.
Root cause suggestion
This looks like a 12-hour AM/PM formatting bug in the date-to-ISO 8601 string conversion. The offset +01:00 is correctly applied, but the hour component is being formatted in 12-hour mode without the PM indicator, effectively dropping 12 hours from any PM time.
Check the date formatter — it may be using h (12-hour) instead of H or HH (24-hour) in the format string, or a locale-dependent formatter that defaults to 12-hour on some systems. Since this is Swift/EventKit, check if DateFormatter.dateFormat uses HH for 24-hour time in ISO 8601 output, or better yet use ISO8601DateFormatter which handles this correctly.
Environment
- OS: macOS (Apple Silicon)
- ekctl version: v1.2.0 (installed via Homebrew)
- Timezone:
Europe/London(BST, UTC+1)
Reported by @MrSimonC
Thanks for the thorough writeup, @MrSimonC — the cross-reference to BRO3886's ical tool was particularly useful as a sanity check that the underlying EventKit data was correct and the bug was purely in our formatting layer.
Root cause is exactly what you suspected, with one extra wrinkle: DateFormatter's HH specifier normally means 24-hour, but when the formatter doesn't pin a locale, it falls back to the user's regional settings — and on hosts where "Use 24-hour time" is disabled in System Preferences (very common in en_GB), HH silently degrades to the locale's preferred clock, dropping to 12-hour without ever emitting an AM/PM marker. That's why you saw the bare 4:00 for 16:00 BST — and also why your 09:00 events looked fine: AM 12-hour and 24-hour values are identical in the morning, so the bug hid until PM.
The fix (in c05dddb) is the standard Apple QA1480 remedy: pin the formatter to en_US_POSIX, which interprets the format string literally and ignores the user's clock preference. Comment in the code explains it for future maintainers.
Closing this out — please reopen if you still see PM times rendering as AM after the next release.