Skip to content

Fix bug for a negative offset with minutes precision #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

Expand Down
4 changes: 4 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down