Skip to content

feat: add 12h/24h/auto time format setting#427

Open
HDash wants to merge 4 commits intorobinebers:mainfrom
HDash:feat/time-format-setting
Open

feat: add 12h/24h/auto time format setting#427
HDash wants to merge 4 commits intorobinebers:mainfrom
HDash:feat/time-format-setting

Conversation

@HDash
Copy link
Copy Markdown

@HDash HDash commented May 1, 2026

Description

Adds a Time Format setting (Auto / 12-hour / 24-hour) to Settings, below Reset Timers. Default Auto preserves existing locale-driven behavior; explicit choices override.

The mode flows from the preferences store through the reset-tooltip formatter, so reset times in provider cards and tooltips render in the user's preferred clock.

Related Issue

Closes #426

Type of Change

  • New feature

Testing

  • npm run build (tsc) — clean
  • npm test — 60 files, 1087 tests passing
  • Manually tested in tauri dev (see screenshots)

Screenshots

Before — current main, no time format option:

before

After — new Time Format section in Settings:

settings

After — provider card rendering reset time in the chosen format:

main

Checklist

  • My PR targets the main branch
  • No new dependencies introduced

HDash added 3 commits May 1, 2026 13:35
Adds TimeFormatMode ("auto" | "12h" | "24h") with load/save helpers,
default "auto" so existing locale-based behavior is preserved.
Replaces the module-level RESET_TIME_FORMATTER with a cached
getTimeFormatter(mode). formatResetAbsoluteLabel and
formatResetTooltipText accept an optional timeFormat param
(default "auto") so existing call sites stay valid.
Adds a Time Format section to Settings (below Reset Timers) with
Auto / 12-hour / 24-hour radios and live previews. Default "Auto"
follows OS locale; explicit choices override.

The chosen mode flows from the preferences store through
app-content -> overview/provider-detail -> provider-card to the
reset-tooltip formatter, so reset times in cards and tooltips
render in the user's preferred clock.
Copilot AI review requested due to automatic review settings May 1, 2026 12:42
@github-actions github-actions Bot added the core label May 1, 2026
@HDash HDash changed the title Add 12h/24h/auto time format setting feat: add 12h/24h/auto time format setting May 1, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 16 files

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a user-configurable time format preference (Auto / 12-hour / 24-hour) and threads it through settings persistence and reset-time formatting so provider card reset labels/tooltips render using the selected clock format.

Changes:

  • Introduces TimeFormatMode + persistence helpers (loadTimeFormatMode / saveTimeFormatMode) and app preference store wiring.
  • Adds a new “Time Format” section to Settings with live previews and update actions.
  • Threads timeFormatMode through app content → pages → provider cards → reset label/tooltip formatter, with new/updated tests.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/stores/app-preferences-store.ts Adds timeFormatMode state + setter to the app preferences store.
src/pages/settings.tsx Renders new Time Format setting UI and uses the shared formatter for previews.
src/pages/settings.test.tsx Adds coverage for the new Settings “Time Format” section and click behavior.
src/pages/provider-detail.tsx Passes timeFormatMode through to ProviderCard (defaulting to auto).
src/pages/overview.tsx Passes timeFormatMode through to ProviderCard (defaulting to auto).
src/lib/settings.ts Defines TimeFormatMode, option list, and persistence load/save functions.
src/lib/settings.test.ts Adds persistence tests for loading/saving/validating time format mode.
src/lib/reset-tooltip.ts Adds cached getTimeFormatter and threads time format into absolute reset labels/tooltips.
src/lib/reset-tooltip.test.ts Adds tests for 12h/24h formatting and timeFormat threading.
src/hooks/app/use-settings-display-actions.ts Persists/tracks time format changes via new action handler.
src/hooks/app/use-settings-display-actions.test.ts Updates tests to include the new time format action behavior.
src/hooks/app/use-settings-bootstrap.ts Bootstraps timeFormatMode from the settings store at startup.
src/hooks/app/use-settings-bootstrap.test.ts Updates bootstrap tests to mock/load the new setting.
src/components/provider-card.tsx Threads timeFormatMode into reset label + tooltip formatting.
src/components/app/app-content.tsx Reads timeFormatMode from store and passes to pages/settings.
src/App.tsx Wires bootstrap + settings actions to setTimeFormatMode / handler prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/app/use-settings-display-actions.test.ts
Comment thread src/hooks/app/use-settings-display-actions.test.ts
Comment thread src/lib/settings.ts Outdated
Comment thread src/lib/reset-tooltip.test.ts Outdated
Comment thread src/hooks/app/use-settings-display-actions.test.ts
- Rename TIME_FORMAT_KEY value "timeFormat" -> "timeFormatMode"
  to match the themeMode/displayMode/resetTimerDisplayMode pattern.
- Make the new reset-tooltip tests locale-independent by deriving
  expected strings via getTimeFormatter(mode) instead of hardcoded
  "AM/PM" / "14:05" literals.
- Add the missing setMenubarIconStyle stub to the three
  useSettingsDisplayActions test sites so test inputs match the
  hook signature.
@HDash
Copy link
Copy Markdown
Author

HDash commented May 1, 2026

Thanks @copilot — addressed in 456d8d2:

  • TIME_FORMAT_KEY naming — renamed the stored key value from "timeFormat" to "timeFormatMode" to match themeMode / displayMode / resetTimerDisplayMode. Test storage stubs updated. No migration needed since the key has not shipped.
  • Locale-dependent assertions in reset-tooltip.test.ts — rewrote the new tests to derive expected strings via getTimeFormatter("12h" | "24h").format(...) and assert equality, instead of matching literal "AM/PM" / "14:05". Two of the original three tests were consolidated into one since they now share the same setup; the differ-sanity check (expected12 !== expected24) preserves the intent of verifying the formats actually diverge.
  • Missing setMenubarIconStyle stub in useSettingsDisplayActions tests (3 sites) — added setMenubarIconStyle: vi.fn() to the main, toggle, and error-logging test invocations. Pre-existing gap (test files are excluded from tsc, so this was silent), but agreed it's safer to keep the test inputs representative of the hook's full signature.

Local: tsc --noEmit clean, vitest run 60 files / 1086 tests passing.

@validatedev
Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator

@validatedev validatedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues. Looks good to me, and feels like a good improvement. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting to override clock format (12h / 24h)

3 participants