From 1d36ec5c20fc47df80a5901d08635f9db9664df1 Mon Sep 17 00:00:00 2001 From: CYRyo Date: Sat, 27 Jun 2026 16:34:58 +0800 Subject: [PATCH] fix(utc): handle short UTC offset format without minutes offsetFromString returns NaN for offsets like "+08" or "-05" (without minutes component). The regex REGEX_VALID_OFFSET_FORMAT correctly accepts these formats, but the destructured minutesOffset is undefined when no minutes group is captured, causing (+undefined * 60) + NaN. Default minutesOffset to 0 when not captured. --- src/plugin/utc/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index d565f3281..2383aafb5 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -11,7 +11,7 @@ function offsetFromString(value = '') { } const [indicator, hoursOffset, minutesOffset] = `${offset[0]}`.match(REGEX_OFFSET_HOURS_MINUTES_FORMAT) || ['-', 0, 0] - const totalOffsetInMinutes = (+hoursOffset * 60) + (+minutesOffset) + const totalOffsetInMinutes = (+hoursOffset * 60) + (+(minutesOffset || 0)) if (totalOffsetInMinutes === 0) { return 0