Skip to content

Commit

Permalink
Fixed issue with invalid dates in Lima Peru at midnight on 1990
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhakes committed Feb 10, 2020
1 parent d514f2f commit 2f20226
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/fecha.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/fecha.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/fecha.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/fecha.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/fecha.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/fecha.umd.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/fecha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ function parse(
// Check to make sure the date field is within the allowed range. Javascript dates allows values
// outside the allowed range. If the values don't match the value was invalid
if (
specifiedFields[validateFields[i][0]] &&
dateInfo[validateFields[i][0]] !== dateWithoutTZ[validateFields[i][1]]()
) {
return null;
Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ function testFormat(name, dateObj, format, expected) {
assert.equal(fecha.format(dateObj, format), expected);
});
}
testParse(
"Lima Peru timezone issue",
"1990-01-01",
"YYYY-MM-DD",
new Date(1990, 0, 1)
);
testParse("leap date", "2020-02-29", "YYYY-MM-DD", new Date(2020, 1, 29));
testParse("leap date wrong year", "2019-02-29", "YYYY-MM-DD", null);
testParse(
Expand Down

0 comments on commit 2f20226

Please sign in to comment.