This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new c926eeff1 fix(lite-topic): render LiteTopic instants in the shared UTC 
formatter (#6479)
c926eeff1 is described below

commit c926eeff1f027835637aadf1c63871f95c5c8859
Author: 0 <[email protected]>
AuthorDate: Thu Oct 15 20:20:41 2026 +0800

    fix(lite-topic): render LiteTopic instants in the shared UTC formatter 
(#6479)
    
    * fix(lite-topic): render LiteTopic instants through the UTC-based formatter
    
    create/last-active times are epoch millis, but formatTime rendered them
    with Date.toLocaleString: locale-dependent, converted to the browser's
    zone, and unlabeled. Route them through formatUtcDateTime like the alert
    surfaces and pin the zone-labeled shape in the test.
    
    Fixes #5225
    
    * test(lite-topic): align the formatTime assertion with the current shared 
formatter
    
    `formatUtcDateTime` renders `YYYY-MM-DD HH:mm:ss` in the viewer's zone and 
no
    longer appends a timezone label, so the regex that still required a trailing
    zone token would fail on trunk. Drop that token and reword both comments to
    describe the formatter as it behaves today.
    
    ---------
    
    Co-authored-by: lizhimins <[email protected]>
---
 web/src/pages/studio/LiteTopic.tsx                | 6 +++++-
 web/src/pages/studio/__tests__/LiteTopic.test.tsx | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/web/src/pages/studio/LiteTopic.tsx 
b/web/src/pages/studio/LiteTopic.tsx
index 3d810a882..9ea9054a3 100644
--- a/web/src/pages/studio/LiteTopic.tsx
+++ b/web/src/pages/studio/LiteTopic.tsx
@@ -16,6 +16,7 @@
  */
 
 import { useCallback, useEffect, useRef, useState } from 'react';
+import { formatUtcDateTime } from '../../utils/format';
 import {
   Table,
   Button,
@@ -70,10 +71,13 @@ const formatDuration = (ms: number | undefined | null): 
string => {
   return `${(ms / 3600000).toFixed(1)}h`;
 };
 
+/* LiteTopic instants (create / last-active) are epoch millis. Render them 
through the shared
+ * formatter like the other timestamp surfaces: a stable `YYYY-MM-DD HH:mm:ss` 
in the viewer's
+ * zone, instead of Date.toLocaleString's locale-dependent browser-local 
string. */
 export const formatTime = (timestamp: number | undefined | null): string => {
   if (timestamp == null || !Number.isFinite(timestamp)) return '-';
   const date = new Date(timestamp);
-  return Number.isNaN(date.getTime()) ? '-' : date.toLocaleString();
+  return Number.isNaN(date.getTime()) ? '-' : formatUtcDateTime(date);
 };
 
 /**
diff --git a/web/src/pages/studio/__tests__/LiteTopic.test.tsx 
b/web/src/pages/studio/__tests__/LiteTopic.test.tsx
index 46622e325..d68051d9a 100644
--- a/web/src/pages/studio/__tests__/LiteTopic.test.tsx
+++ b/web/src/pages/studio/__tests__/LiteTopic.test.tsx
@@ -92,7 +92,10 @@ const createDeferred = <T,>() => {
 
 describe('LiteTopic time formatting', () => {
   it('preserves epoch timestamps and rejects invalid provider values', () => {
-    expect(formatTime(0)).toBe(new Date(0).toLocaleString());
+    // Epoch instants render as a stable `YYYY-MM-DD HH:mm:ss` in the viewer's 
zone, never the
+    // locale-dependent Date.toLocaleString string.
+    expect(formatTime(0)).toMatch(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
+    expect(formatTime(0)).not.toBe(new Date(0).toLocaleString());
     expect(formatTime(Number.POSITIVE_INFINITY)).toBe('-');
     expect(formatTime(Number.MAX_VALUE)).toBe('-');
   });

Reply via email to