Skip to content

Bug: 12-hour AM/PM time formatting error in BST (UTC+1) — PM events displayed as AM #8

@MrSimonC

Description

@MrSimonC

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

  1. Be in a BST timezone (Europe/London, during summer time, UTC+1)
  2. 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
  3. Run:
    ekctl list events --calendar D82CAA49-15DD-438A-AF83-7D4C23BC37CD --from 2026-04-19T00:00:00Z --to 2026-04-20T00:00:00Z
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions