Skip to content

Conversation

@gertjanal
Copy link
Contributor

@gertjanal gertjanal commented Oct 28, 2025

Description

Show either 12-hour or 24-hour notation in the coordinator UI, based on locale.

Additional context and related issues

Note that the offical time format has uppercase AM and PM, whereas the original Trino code uses am and pm.
If we want to stick to that, I could add .toLowerCase(), but I don't think lowercase is needed.
In the old (current) UI, the removed space and lowercase pm is needed because otherwise the text will be too long for the bootstraps xs-2 class. In the preview UI the header is different, so in that case we can stick to the default .toLocaleTimeString

UI
Screenshot 2025-11-07 at 14-39-55 Cluster Overview - Trino

Screenshot 2025-11-07 at 14-36-58 Cluster Overview - Trino

Preview UI
Screenshot 2025-11-07 at 14-39-40 Trino - Preview UI

Screenshot 2025-11-07 at 14-37-12 Trino - Preview UI

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( X ) Release notes are required, with the following suggested text:

## User interface
* Use browser locale to format time

Summary by Sourcery

Format short times in the coordinator UI using the browser's locale to automatically support 12-hour or 24-hour notation.

New Features:

  • Support displaying times in 12-hour or 24-hour notation based on the user's locale

Enhancements:

  • Replace manual formatShortTime implementation with toLocaleTimeString in both utils.ts and utils.js

Documentation:

  • Add release note for user interface to use browser locale to format time

@cla-bot cla-bot bot added the cla-signed label Oct 28, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces manual time formatting logic in the UI utilities with a locale-aware toLocaleTimeString call for short time display, automatically supporting both 12-hour and 24-hour notations.

Class diagram for updated time formatting utility functions

classDiagram
    class Utils {
      +parseDuration(value: string): number | null
      +formatShortTime(date: Date): string
      +formatShortDateTime(date: Date): string
      formatShortTime(date: Date) now uses toLocaleTimeString with timeStyle: 'short'
    }
Loading

File-Level Changes

Change Details Files
Switch formatShortTime to use locale-based formatting
  • Removed manual computation of hours and minutes
  • Eliminated hardcoded AM/PM suffix
  • Replaced with date.toLocaleTimeString([], { timeStyle: 'short' })
core/trino-web-ui/src/main/resources/webapp-preview/src/utils/utils.ts
core/trino-web-ui/src/main/resources/webapp/src/utils.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the ui Web UI label Oct 28, 2025
Copy link

@sourcery-ai sourcery-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.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider specifying the hour12 option (e.g., { hour: 'numeric', minute: 'numeric', hour12: true/false }) in toLocaleTimeString to explicitly control 12h vs 24h formats rather than relying solely on locale defaults.
  • Ensure any UI tests or snapshots that expected the old lowercase “am”/“pm” output are updated to handle the new locale-based formatting, which may vary in casing or notation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider specifying the hour12 option (e.g., { hour: 'numeric', minute: 'numeric', hour12: true/false }) in toLocaleTimeString to explicitly control 12h vs 24h formats rather than relying solely on locale defaults.
- Ensure any UI tests or snapshots that expected the old lowercase “am”/“pm” output are updated to handle the new locale-based formatting, which may vary in casing or notation.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

Could you add a screenshot to the PR description?

@gertjanal gertjanal force-pushed the show-12-or-24-hour-timestamp-in-ui branch from 37465ea to 3ca3db7 Compare October 29, 2025 19:51
@gertjanal
Copy link
Contributor Author

Could you add a screenshot to the PR description?

Added

@gertjanal gertjanal force-pushed the show-12-or-24-hour-timestamp-in-ui branch from 3ca3db7 to f577dfd Compare November 3, 2025 19:33
@ebyhr ebyhr requested review from koszti and wendigo November 11, 2025 00:32
Copy link
Member

@koszti koszti left a comment

Choose a reason for hiding this comment

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

I tried it on both UIs. LGTM

@wendigo wendigo merged commit 33d6fd5 into trinodb:master Nov 20, 2025
195 of 197 checks passed
@github-actions github-actions bot added this to the 479 milestone Nov 20, 2025
@ebyhr
Copy link
Member

ebyhr commented Nov 21, 2025

Show time based on locale to support 12 hour and 24 hour notation in UI.

@gertjanal Please follow commit message guidelines from next time: https://trino.io/development/process.html#pull-request-and-commit-guidelines

  • Limit the subject line to 50 characters.
  • Do not end the subject line with a period.

@chenjian2664
Copy link
Contributor

@gertjanal Could you update the release note section?

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

Labels

Development

Successfully merging this pull request may close these issues.

5 participants