From c9b836f48986ae78a380d897e7b32201aa4031c2 Mon Sep 17 00:00:00 2001 From: fabon Date: Fri, 25 Jul 2025 23:09:16 +0900 Subject: [PATCH] Fix bug for a negative offset with minutes precision --- parse.js | 3 ++- test/utils.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/parse.js b/parse.js index c0976c9..b44de39 100644 --- a/parse.js +++ b/parse.js @@ -20,9 +20,10 @@ export class IsoDateParts { } let [hours, minutes] = [match[1], match[2]]; + let sign = hours[0] === '-' ? -1 : 1; return { hours: parseInt(hours, 10) || 0, - minutes: parseInt(minutes, 10) || 0 + minutes: (parseInt(minutes, 10) || 0) * sign }; } diff --git a/test/utils.js b/test/utils.js index 37b564e..8bdaf95 100644 --- a/test/utils.js +++ b/test/utils.js @@ -25,11 +25,13 @@ export const VALID_TEST_CASES = ` 2016-05-25T09+01:00 2016-05-25T09:24+01:00 2016-05-25T09:24:15+01:00 +2016-05-25T09:24:15+01:15 2016-05-25T09:24:15.123+01:00 2016-05-25T09:24:15,123+01:00 2016-05-25T09-01:00 2016-05-25T09:24-01:00 2016-05-25T09:24:15-01:00 +2016-05-25T09:24:15-01:15 2016-05-25T09:24:15.123-01:00 2016-05-25T09:24:15,123-01:00 2016-05-25T09+06:00 @@ -73,8 +75,10 @@ export const VALID_TEST_CASES = ` // Issue #1 2016-05-25T09:24:15+06 2016-05-25T09:24:15+0600 +2016-05-25T09:24:15+0615 2016-05-25T09:24:15-06 2016-05-25T09:24:15-0600 +2016-05-25T09:24:15-0615 // 6 digit years +002000-01-01