davidradl commented on code in PR #27552:
URL: https://github.com/apache/flink/pull/27552#discussion_r2924877449
##########
flink-runtime-web/web-dashboard/src/app/components/humanize-watermark.pipe.ts:
##########
@@ -36,16 +37,67 @@ export class HumanizeWatermarkPipe implements PipeTransform
{
}
@Pipe({
- name: 'humanizeWatermarkToDatetime'
+ name: 'humanizeWatermarkToDatetime',
+ standalone: true
})
export class HumanizeWatermarkToDatetimePipe implements PipeTransform {
constructor(private readonly configService: ConfigService) {}
- public transform(value: number): number | string {
+ public transform(value: number, timezone: string = 'UTC'): number | string {
if (value == null || isNaN(value) || value <=
this.configService.LONG_MIN_VALUE) {
return 'N/A';
- } else {
- return new Date(value).toLocaleString();
+ }
+
+ try {
+ const date = new Date(value);
+
+ // Use Intl.DateTimeFormat for proper timezone handling including DST
+ // This native browser API automatically handles daylight saving time
transitions
+ // Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
+ const dateFormatter = new Intl.DateTimeFormat('en-US', {
+ timeZone: timezone,
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ hour12: false,
+ minute: '2-digit',
+ second: '2-digit'
+ });
+
+ // Get timezone abbreviation (e.g., PST, PDT, EST, EDT)
+ // The abbreviation automatically reflects DST status (e.g., PST vs PDT)
+ const timezoneFormatter = new Intl.DateTimeFormat('en-US', {
Review Comment:
I thought we were going to interrogate the browser for its timezone and use
that if possible, and if we cannot then use UTF. It looks like we are hard
coding en-US - this is not what I expected. Have I understood this correctly?
--
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]