Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(web): show the DST-aware UTC offset for timezones (#43627)
Juhyuk choi1759587078d2
diff --git a/web/app/components/workflow/nodes/trigger-schedule/utils/__tests__/execution-time-label.spec.ts b/web/app/components/workflow/nodes/trigger-schedule/utils/__tests__/execution-time-label.spec.tsnew file mode 100644index 00000000000..5078ecae1a5--- /dev/null+++ b/web/app/components/workflow/nodes/trigger-schedule/utils/__tests__/execution-time-label.spec.ts@@ -0,0 +1,104 @@+import type { ScheduleTriggerNodeType } from '../../types'+import { BlockEnum } from '../../../../types'+import { getFormattedExecutionTimes } from '../execution-time-calculator'++describe('execution time offset label', () => {+ afterEach(() => {+ vi.useRealTimers()+ })++ it('shows the offset in effect on each run date across the end of DST', () => {+ vi.useFakeTimers()+ vi.setSystemTime(new Date('2026-10-30T12:00:00Z'))++ const data = {+ type: BlockEnum.TriggerSchedule,+ title: 'schedule',+ mode: 'visual',+ frequency: 'daily',+ timezone: 'America/New_York',+ visual_config: { time: '12:00 AM' },+ } as ScheduleTriggerNodeType++ const times = getFormattedExecutionTimes(data, 4)++ expect(times[0]).toContain('October 31, 2026')+ expect(times[0]).toContain('(UTC-4)')+ expect(times[1]).toContain('November 1, 2026')+ expect(times[1]).toContain('(UTC-4)')+ expect(times[2]).toContain('November 2, 2026')+ expect(times[2]).toContain('(UTC-5)')+ })++ it('labels the repeated hour by its real offset when DST ends', () => {+ vi.useFakeTimers()+ vi.setSystemTime(new Date('2026-11-01T03:00:00Z'))++ const data = {+ type: BlockEnum.TriggerSchedule,+ title: 'schedule',+ mode: 'cron',+ cron_expression: '30 * * * *',+ timezone: 'America/New_York',+ } as ScheduleTriggerNodeType++ const times = getFormattedExecutionTimes(data, 5)++ expect(times[2]).toMatch(/November 1, 2026, 1:30\sAM \(UTC-4\)/)+ expect(times[3]).toMatch(/November 1, 2026, 1:30\sAM \(UTC-5\)/)+ })++ it('labels the upcoming repeated hour in visual daily mode', () => {+ vi.useFakeTimers()+ vi.setSystemTime(new Date('2026-11-01T06:05:00Z'))++ const data = {+ type: BlockEnum.TriggerSchedule,+ title: 'schedule',+ mode: 'visual',+ frequency: 'daily',+ timezone: 'America/New_York',+ visual_config: { time: '1:30 AM' },+ } as ScheduleTriggerNodeType++ const times = getFormattedExecutionTimes(data, 2)++ expect(times[0]).toMatch(/November 1, 2026, 1:30\sAM \(UTC-5\)/)+ })++ it('labels the upcoming repeated hour in visual hourly mode', () => {+ vi.useFakeTimers()+ vi.setSystemTime(new Date('2026-11-01T06:05:00Z'))++ const data = {+ type: BlockEnum.TriggerSchedule,+ title: 'schedule',+ mode: 'visual',+ frequency: 'hourly',+ timezone: 'America/New_York',+ visual_config: { on_minute: 30 },+ } as ScheduleTriggerNodeType++ const times = getFormattedExecutionTimes(data, 1)++ expect(times[0]).toMatch(/November 1, 2026, 1:30\sAM \(UTC-5\)/)+ })++ it('labels the first repeated hour in a zone far ahead of UTC', () => {+ vi.useFakeTimers()+ vi.setSystemTime(new Date('2026-04-04T08:00:00Z'))++ const data = {+ type: BlockEnum.TriggerSchedule,+ title: 'schedule',+ mode: 'visual',+ frequency: 'daily',+ timezone: 'Pacific/Auckland',+ visual_config: { time: '2:00 AM' },+ } as ScheduleTriggerNodeType++ const times = getFormattedExecutionTimes(data, 1)++ expect(times[0]).toMatch(/April 5, 2026, 2:00\sAM \(UTC\+13\)/)+ })+})diff --git a/web/app/components/workflow/nodes/trigger-schedule/utils/cron-parser.ts b/web/app/components/workflow/nodes/trigger-schedule/utils/cron-parser.tsindex 1fae66bfec2..f56fe7dc04c 100644--- a/web/app/components/workflow/nodes/trigger-schedule/utils/cron-parser.ts+++ b/web/app/components/workflow/nodes/trigger-schedule/utils/cron-parser.ts@@ -2,7 +2,7 @@ import { CronExpressionParser } from 'cron-parser'// Convert a UTC date from cron-parser to user timezone representation// This ensures consistency with other execution time calculations-const convertToUserTimezoneRepresentation = (utcDate: Date, timezone: string): Date => {+export const convertToUserTimezoneRepresentation = (utcDate: Date, timezone: string): Date => {// Get the time string in the target timezoneconst userTimeStr = utcDate.toLocaleString('en-CA', {timeZone: timezone,@@ -18,13 +18,16 @@ const convertToUserTimezoneRepresentation = (utcDate: Date, timezone: string): D}/**- * Parse a cron expression and return the next 5 execution times+ * Parse a cron expression and return the next 5 execution instants (real UTC times)** @param cronExpression - Standard 5-field cron expression (minute hour day month dayOfWeek)* @param timezone - IANA timezone identifier (e.g., 'UTC', 'America/New_York')- * @returns Array of Date objects representing the next 5 execution times+ * @returns Array of Date objects holding the real instant of each run*/-export const parseCronExpression = (cronExpression: string, timezone: string = 'UTC'): Date[] => {+export const getCronExecutionInstants = (+ cronExpression: string,+ timezone: string = 'UTC',+): Date[] => {if (!cronExpression || cronExpression.trim() === '') return []const parts = cronExpression.trim().split(/\s+/)@@ -33,27 +36,28 @@ export const parseCronExpression = (cronExpression: string, timezone: string = 'if (parts.length !== 5 && !cronExpression.startsWith('@')) return []try {- // Parse the cron expression with timezone support- // Use the actual current time for cron-parser to handle properlyconst interval = CronExpressionParser.parse(cronExpression, {tz: timezone,})-- // Get the next 5 execution times using the take() method- const nextCronDates = interval.take(5)-- // Convert CronDate objects to Date objects and ensure they represent- // the time in user timezone (consistent with execution-time-calculator.ts)- return nextCronDates.map((cronDate) => {- const utcDate = cronDate.toDate()- return convertToUserTimezoneRepresentation(utcDate, timezone)- })+ return interval.take(5).map((cronDate) => cronDate.toDate())} catch {// Return empty array if parsing failsreturn []}}+/**+ * Parse a cron expression and return the next 5 execution times+ *+ * @param cronExpression - Standard 5-field cron expression (minute hour day month dayOfWeek)+ * @param timezone - IANA timezone identifier (e.g., 'UTC', 'America/New_York')+ * @returns Array of Date objects representing the next 5 execution times+ */+export const parseCronExpression = (cronExpression: string, timezone: string = 'UTC'): Date[] =>+ getCronExecutionInstants(cronExpression, timezone).map((instant) =>+ convertToUserTimezoneRepresentation(instant, timezone),+ )+/*** Validate a cron expression format and syntax*diff --git a/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts b/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.tsindex 90d5b66093c..29f1d6f0031 100644--- a/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts+++ b/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts@@ -1,6 +1,11 @@import type { ScheduleTriggerNodeType } from '../types'-import { convertTimezoneToOffsetStr } from '@/utils/timezone'-import { isValidCronExpression, parseCronExpression } from './cron-parser'+import { convertTimezoneToOffsetStr, getTimezoneOffsetMinutes } from '@/utils/timezone'+import {+ convertToUserTimezoneRepresentation,+ getCronExecutionInstants,+ isValidCronExpression,+ parseCronExpression,+} from './cron-parser'const DEFAULT_TIMEZONE = 'UTC'@@ -28,6 +33,34 @@ const getUserTimezoneCurrentTime = (timezone?: string): Date => {return new Date(year!, month! - 1, day, hour, minute, second)}+// The Date objects here hold the wall time of the target timezone in local fields.+// Turn that wall time back into the real instant so the offset label follows DST.+// When DST ends, one wall time happens twice. Pick the first one that is not in the past.+const getWallTimeInstant = (date: Date, timezone: string): Date => {+ const wallAsUtc = Date.UTC(+ date.getFullYear(),+ date.getMonth(),+ date.getDate(),+ date.getHours(),+ date.getMinutes(),+ date.getSeconds(),+ )+ const offsetAt = (time: number) => getTimezoneOffsetMinutes(timezone, new Date(time)) ?? 0+ // Offsets a day before and after cover both sides of any DST change near this wall time.+ const offsetsNearby = [offsetAt(wallAsUtc - 24 * 3_600_000), offsetAt(wallAsUtc + 24 * 3_600_000)]+ const candidates = [...new Set(offsetsNearby)]+ .map((offset) => wallAsUtc - offset * 60_000)+ .filter((time) => offsetAt(time) === (wallAsUtc - time) / 60_000)+ .sort((a, b) => a - b)++ // No candidate means the wall time falls in the DST gap. The run happens after+ // the clocks move forward, so the label shows the new offset.+ if (candidates.length === 0) return new Date(wallAsUtc - offsetsNearby[0]! * 60_000)++ const now = Date.now()+ return new Date(candidates.find((time) => time >= now) ?? candidates[0]!)+}+// Format date that is already in user timezone, no timezone conversionconst formatUserTimezoneDate = (date: Date,@@ -53,7 +86,7 @@ const formatUserTimezoneDate = (const timeStr = date.toLocaleTimeString('en-US', timeOptions)if (includeTimezone) {- const timezoneOffset = convertTimezoneToOffsetStr(timezone)+ const timezoneOffset = convertTimezoneToOffsetStr(timezone, getWallTimeInstant(date, timezone))return `${dateStr}, ${timeStr} (${timezoneOffset})`}@@ -268,6 +301,17 @@ export const getFormattedExecutionTimes = (count: number = 5,): string[] => {const timezone = resolveTimezone(data.timezone)+ // Cron runs can repeat a wall time when DST ends, so label each run from its real instant.+ if (data.mode === 'cron') {+ if (!data.cron_expression || !isValidCronExpression(data.cron_expression)) return []+ return getCronExecutionInstants(data.cron_expression, timezone)+ .slice(0, count)+ .map((instant) => {+ const wallTime = convertToUserTimezoneRepresentation(instant, timezone)+ const label = formatUserTimezoneDate(wallTime, timezone, false, false)+ return `${label} (${convertTimezoneToOffsetStr(timezone, instant)})`+ })+ }const times = getNextExecutionTimes(data, count)return times.map((date) => {diff --git a/web/utils/__tests__/timezone.spec.ts b/web/utils/__tests__/timezone.spec.tsnew file mode 100644index 00000000000..b8b30fc8421--- /dev/null+++ b/web/utils/__tests__/timezone.spec.ts@@ -0,0 +1,27 @@+import { convertTimezoneToOffsetStr } from '../timezone'++describe('convertTimezoneToOffsetStr', () => {+ it('follows daylight saving time for the given date', () => {+ expect(convertTimezoneToOffsetStr('America/New_York', new Date('2026-07-01T12:00:00Z'))).toBe(+ 'UTC-4',+ )+ expect(convertTimezoneToOffsetStr('America/New_York', new Date('2026-01-15T12:00:00Z'))).toBe(+ 'UTC-5',+ )+ })++ it('keeps minutes for half-hour offsets', () => {+ expect(convertTimezoneToOffsetStr('Asia/Kolkata', new Date('2026-07-01T12:00:00Z'))).toBe(+ 'UTC+5:30',+ )+ expect(convertTimezoneToOffsetStr('America/St_Johns', new Date('2026-01-15T12:00:00Z'))).toBe(+ 'UTC-3:30',+ )+ })++ it('returns UTC+0 for UTC, a missing timezone, and an unknown timezone', () => {+ expect(convertTimezoneToOffsetStr('UTC')).toBe('UTC+0')+ expect(convertTimezoneToOffsetStr(undefined)).toBe('UTC+0')+ expect(convertTimezoneToOffsetStr('Not/AZone')).toBe('UTC+0')+ })+})diff --git a/web/utils/timezone.ts b/web/utils/timezone.tsindex 84a18666105..295c86923a2 100644--- a/web/utils/timezone.ts+++ b/web/utils/timezone.ts@@ -14,20 +14,47 @@ export const getBrowserTimezone = () => {const DEFAULT_OFFSET_STR = 'UTC+0'-export const convertTimezoneToOffsetStr = (timezone?: string) => {+const formatOffset = (totalMinutes: number) => {+ const sign = totalMinutes >= 0 ? '+' : '-'+ const absMinutes = Math.abs(totalMinutes)+ const hours = Math.floor(absMinutes / 60)+ const minutes = absMinutes % 60+ return minutes !== 0+ ? `UTC${sign}${hours}:${String(minutes).padStart(2, '0')}`+ : `UTC${sign}${hours}`+}++// Offset in minutes of a timezone at a given instant, following DST. Undefined if the runtime cannot resolve it.+export const getTimezoneOffsetMinutes = (timezone: string, date: Date): number | undefined => {+ try {+ const name = new Intl.DateTimeFormat('en-US', {+ timeZone: timezone,+ timeZoneName: 'longOffset',+ })+ .formatToParts(date)+ .find((part) => part.type === 'timeZoneName')?.value+ if (name === 'GMT') return 0+ const match = name ? /^GMT([+-])(\d{2}):(\d{2})$/.exec(name) : null+ if (!match) return undefined+ const totalMinutes = Number(match[2]) * 60 + Number(match[3])+ return match[1] === '-' ? -totalMinutes : totalMinutes+ } catch {+ return undefined+ }+}++export const convertTimezoneToOffsetStr = (timezone?: string, date: Date = new Date()) => {if (!timezone) return DEFAULT_OFFSET_STR+ const offsetMinutes = getTimezoneOffsetMinutes(timezone, date)+ if (offsetMinutes !== undefined) return formatOffset(offsetMinutes)const tzItem = tz.find((item) => item.value === timezone)if (!tzItem) return DEFAULT_OFFSET_STR- // Extract offset from name format like "-11:00 Niue Time" or "+05:30 India Time"- // Name format is always "{offset}:{minutes} {timezone name}"+ // Fallback for runtimes without the timezone. Extract the standard offset from names like "-11:00 Niue Time".const offsetMatch = /^([+-]?\d{1,2}):(\d{2})/.exec(tzItem.name)/* v8 ignore next 2 -- timezone.json entries are normalized to "{offset} {name}"; this protects against malformed data only. */if (!offsetMatch) return DEFAULT_OFFSET_STR- // Parse hours and minutes separatelyconst hours = Number.parseInt(offsetMatch[1]!, 10)const minutes = Number.parseInt(offsetMatch[2]!, 10)const sign = hours >= 0 ? '+' : ''- // If minutes are non-zero, include them in the output (e.g., "UTC+5:30")- // Otherwise, only show hours (e.g., "UTC+8")return minutes !== 0 ? `UTC${sign}${hours}:${offsetMatch[2]}` : `UTC${sign}${hours}`}