yuchen-ecnu commented on code in PR #27552:
URL: https://github.com/apache/flink/pull/27552#discussion_r2888626773
##########
flink-runtime-web/web-dashboard/src/app/pages/job/overview/watermarks/job-overview-drawer-watermarks.component.ts:
##########
@@ -62,7 +83,56 @@ export class JobOverviewDrawerWatermarksComponent implements
OnInit, OnDestroy {
private readonly cdr: ChangeDetectorRef
) {}
+ private getBrowserTimezone(): string {
+ // Get browser's IANA timezone identifier
+ // This will properly handle DST changes
+ // Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions
+ try {
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
+ } catch (error) {
+ console.error('[getBrowserTimezone] Error getting browser timezone,
falling back to UTC:', error);
+ // As a last resort, rely on runtime environment offset
+ const offset = -new Date().getTimezoneOffset();
+ const sign = offset >= 0 ? '+' : '-';
Review Comment:
According to the [IANA Time Zone Database
(etcetera)](https://github.com/eggert/tz/blob/main/etcetera) and
[Wikipedia](https://en.wikipedia.org/wiki/Tz_database#Area), the Etc/GMT area
uses POSIX-style signs, which are the opposite of ISO-8601:
* Etc/GMT-8 = UTC+8 (East of Greenwich)
* Etc/GMT+8 = UTC-8 (West of Greenwich)
Let's try following code,
```javascript
> console.log("PR (+8):", new Date().toLocaleString('en-US', { timeZone:
'Etc/GMT+8' }));
PR (+8): 3/5/2026, 12:50:03 AM
> console.log("Correct (-8):", new Date().toLocaleString('en-US', {
timeZone: 'Etc/GMT-8' }));
Correct (-8): 3/5/2026, 4:50:18 PM
> new Date()
Thu Mar 05 2026 16:50:35 GMT+0800 (中国标准时间)
```
##########
flink-runtime-web/web-dashboard/src/app/pages/job/overview/watermarks/job-overview-drawer-watermarks.component.ts:
##########
@@ -62,7 +83,56 @@ export class JobOverviewDrawerWatermarksComponent implements
OnInit, OnDestroy {
private readonly cdr: ChangeDetectorRef
) {}
+ private getBrowserTimezone(): string {
+ // Get browser's IANA timezone identifier
+ // This will properly handle DST changes
+ // Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions
+ try {
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
+ } catch (error) {
+ console.error('[getBrowserTimezone] Error getting browser timezone,
falling back to UTC:', error);
+ // As a last resort, rely on runtime environment offset
+ const offset = -new Date().getTimezoneOffset();
+ const sign = offset >= 0 ? '+' : '-';
+ const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, '0');
Review Comment:
The `padStart(2, '0')` produces strings like `Etc/GMT+08`, which causes a
RangeError: Invalid time zone specified in most browsers. Canonical Etc/GMT
names do not have leading zeros (it should be Etc/GMT+8)."
You can verify by following code in the browser developer console:
```javascript
const timezoneFormatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'Etc/GMT+08',
timeZoneName: 'short'
});
```
<img width="510" height="184" alt="Image"
src="https://github.com/user-attachments/assets/cd06c9a6-2065-4e75-be8c-ff1b05a0ade6"
/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]