Skip to content

Commit c9b836f

Browse files
committed
Fix bug for a negative offset with minutes precision
1 parent a22985e commit c9b836f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export class IsoDateParts {
2020
}
2121

2222
let [hours, minutes] = [match[1], match[2]];
23+
let sign = hours[0] === '-' ? -1 : 1;
2324
return {
2425
hours: parseInt(hours, 10) || 0,
25-
minutes: parseInt(minutes, 10) || 0
26+
minutes: (parseInt(minutes, 10) || 0) * sign
2627
};
2728
}
2829

test/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ export const VALID_TEST_CASES = `
2525
2016-05-25T09+01:00
2626
2016-05-25T09:24+01:00
2727
2016-05-25T09:24:15+01:00
28+
2016-05-25T09:24:15+01:15
2829
2016-05-25T09:24:15.123+01:00
2930
2016-05-25T09:24:15,123+01:00
3031
2016-05-25T09-01:00
3132
2016-05-25T09:24-01:00
3233
2016-05-25T09:24:15-01:00
34+
2016-05-25T09:24:15-01:15
3335
2016-05-25T09:24:15.123-01:00
3436
2016-05-25T09:24:15,123-01:00
3537
2016-05-25T09+06:00
@@ -73,8 +75,10 @@ export const VALID_TEST_CASES = `
7375
// Issue #1
7476
2016-05-25T09:24:15+06
7577
2016-05-25T09:24:15+0600
78+
2016-05-25T09:24:15+0615
7679
2016-05-25T09:24:15-06
7780
2016-05-25T09:24:15-0600
81+
2016-05-25T09:24:15-0615
7882
7983
// 6 digit years
8084
+002000-01-01

0 commit comments

Comments
 (0)