Skip to content

feat: Add 12-hour clock format support to TimeCard#49

Merged
Sunwuyuan merged 2 commits intomainfrom
copilot/add-12h-clock-option
Mar 22, 2026
Merged

feat: Add 12-hour clock format support to TimeCard#49
Sunwuyuan merged 2 commits intomainfrom
copilot/add-12h-clock-option

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

The clock card only supported 24h display. This adds a user-toggleable 12h (AM/PM) mode.

Changes

  • src/utils/settings.js: Registers timeCard.use12h (boolean, default false)
  • TimeCard.vue:
    • timeString computed: converts to 12h (1–12, no leading zero) when enabled
    • amPmString computed: returns 'AM' or 'PM'
    • Template: renders AM/PM indicator after seconds in both card and fullscreen views
    • Settings dialog: new "12 小时制" toggle switch persisted via setSetting

When 12h mode is on, 9:05 AM is displayed rather than 09:05.

Original prompt

This section details on the original issue you should resolve

<issue_title>【建议】时钟卡片支持 12h 制</issue_title>
<issue_description>如题所诉喵</issue_description>

<agent_instructions>实现此功能,添加一个设置选项</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 21, 2026

Deploying classworks with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1bc9d2f
Status: ✅  Deploy successful!
Preview URL: https://8f309292.classworks.pages.dev
Branch Preview URL: https://copilot-add-12h-clock-option.classworks.pages.dev

View logs

Copilot AI changed the title [WIP] Add 12h clock mode support for clock card feat: Add 12-hour clock format support to TimeCard Mar 21, 2026
Copilot AI requested a review from Sunwuyuan March 21, 2026 07:45
@Sunwuyuan Sunwuyuan marked this pull request as ready for review March 22, 2026 06:09
Copilot AI review requested due to automatic review settings March 22, 2026 06:09
@Sunwuyuan Sunwuyuan merged commit fe9d00f into main Mar 22, 2026
5 checks passed
Copy link

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-facing setting to switch the TimeCard display between 24-hour and 12-hour (AM/PM) time formats, addressing the prior lack of 12h support.

Changes:

  • Registered new boolean setting timeCard.use12h (default false) in the settings registry.
  • Updated TimeCard.vue to format hours in 12h mode and compute/render an AM/PM indicator (card + fullscreen).
  • Added a “12 小时制” toggle to the TimeCard settings dialog and persisted it via setSetting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/utils/settings.js Registers the new timeCard.use12h setting so it can be persisted and retrieved consistently.
src/components/TimeCard.vue Implements 12h formatting, AM/PM rendering, and adds a UI toggle wired to settings persistence.

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

v-if="use12hClock"
class="ampm-text"
:style="secondsStyle"
> {{ amPmString }}</span>
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

AM/PM span content includes a leading literal space (> {{ amPmString }}) while secondsStyle already applies margin-left. This results in double/variable spacing depending on font rendering. Prefer removing the leading whitespace and rely on CSS margin (or handle spacing in one place consistently).

Suggested change
> {{ amPmString }}</span>
>{{ amPmString }}</span>

Copilot uses AI. Check for mistakes.
{{ timeString }}<span class="fullscreen-seconds">{{ secondsString }}</span><span
v-if="use12hClock"
class="fullscreen-seconds"
> {{ amPmString }}</span>
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Fullscreen AM/PM span also includes a leading literal space (> {{ amPmString }}) while .fullscreen-seconds already has margin-left: 4px;. This can cause unintended extra spacing; keep spacing in CSS or template, but not both.

Suggested change
> {{ amPmString }}</span>
>{{ amPmString }}</span>

Copilot uses AI. Check for mistakes.
>{{ secondsString }}</span>
>{{ secondsString }}</span><span
v-if="use12hClock"
class="ampm-text"
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

class="ampm-text" is introduced for the AM/PM span, but there is no corresponding .ampm-text rule in this component’s scoped styles. Either add a style (if you intend to differentiate AM/PM) or drop the class to avoid dead/unused selectors.

Suggested change
class="ampm-text"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【建议】时钟卡片支持 12h 制

3 participants