featzhang commented on code in PR #27552:
URL: https://github.com/apache/flink/pull/27552#discussion_r2791809003
##########
flink-runtime-web/web-dashboard/src/app/components/humanize-watermark.pipe.ts:
##########
@@ -36,16 +37,64 @@ 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 = 'auto'): number | string {
+ console.log('[HumanizeWatermarkToDatetimePipe] Transform called with
value:', value, 'timezone:', timezone);
+
if (value == null || isNaN(value) || value <=
this.configService.LONG_MIN_VALUE) {
+ console.log('[HumanizeWatermarkToDatetimePipe] Invalid value, returning
N/A');
return 'N/A';
} else {
- return new Date(value).toLocaleString();
+ let timezoneOffsetMinutes: number;
+
+ // Parse timezone format, e.g. UTC+8, UTC-5, UTC+5:30, etc.
+ const match = timezone.match(/UTC([+-])(\d+)(?::(\d+))?/);
+ if (match) {
+ const sign = match[1] === '+' ? 1 : -1;
+ const hours = parseInt(match[2]);
+ const minutes = match[3] ? parseInt(match[3]) : 0;
+ timezoneOffsetMinutes = sign * (hours * 60 + minutes);
+ console.log('[HumanizeWatermarkToDatetimePipe] Parsed timezone
offset:', timezoneOffsetMinutes, 'minutes');
+ } else {
+ // Default to browser timezone if format is not recognized
+ const browserOffset = new Date().getTimezoneOffset();
+ timezoneOffsetMinutes = -browserOffset; // Convert to UTC offset format
+ console.log(
+ '[HumanizeWatermarkToDatetimePipe] Using browser timezone offset:',
+ timezoneOffsetMinutes,
+ 'minutes'
+ );
+ }
+
+ // Calculate the datetime in the target timezone
+ // value is timestamp in milliseconds (UTC)
+ const utcDate = new Date(value);
+ const targetDate = new Date(utcDate.getTime() + timezoneOffsetMinutes *
60 * 1000);
+
+ const year = targetDate.getUTCFullYear();
Review Comment:
<img width="1199" height="400" alt="image"
src="https://github.com/user-attachments/assets/f3cc7666-bed1-434a-97ae-19abf1d93dcd"
/>
--
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]