Skip to content

Commit

Permalink
Ah, that's why it broke - update changlog, documenting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pineapplemachine committed Dec 31, 2019
1 parent 2649f23 commit decdf87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Fourth release. 31 December 2019.

- Workaround for issue related to Date.setUTCMonth causing misbehavior on New Year's Eve.
- Fix issue related to calling Date.setUTCMonth on the 31st day of the month.

# v1.1.1

Expand Down
4 changes: 2 additions & 2 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ class TimestampParser{
date.setUTCFullYear(this.year);
}
if(this.month !== undefined){
// Workaround fixes New Year's Eve issue for some reason
// https://github.com/pineapplemachine/strtime-js/issues/5
date.setUTCMonth(1);
// https://stackoverflow.com/questions/26681313/javascript-setutcmonth-does-not-work-for-november
date.setUTCMonth(0, 1);
date.setUTCMonth(this.month - 1);
}
if(this.dayOfMonth !== undefined){
Expand Down
8 changes: 4 additions & 4 deletions test/canary-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const dayjs = require("dayjs");
function getDate(options){
const date = new Date();
date.setFullYear(options.year !== undefined ? options.year : 2000);
// Workaround fixes New Year's Eve issue for some reason
// https://github.com/pineapplemachine/strtime-js/issues/5
date.setMonth(1);
// https://stackoverflow.com/questions/26681313/javascript-setutcmonth-does-not-work-for-november
date.setUTCMonth(0, 1);
date.setMonth((options.month || 1) - 1);
date.setDate(options.day || 1);
date.setHours(options.hour || 0);
Expand All @@ -23,9 +23,9 @@ function getDate(options){
function getUTCDate(options){
const date = new Date();
date.setUTCFullYear(options.year !== undefined ? options.year : 2000);
// Workaround fixes New Year's Eve issue for some reason
// https://github.com/pineapplemachine/strtime-js/issues/5
date.setUTCMonth(1);
// https://stackoverflow.com/questions/26681313/javascript-setutcmonth-does-not-work-for-november
date.setUTCMonth(0, 1);
date.setUTCMonth((options.month || 1) - 1);
date.setUTCDate(options.day || 1);
date.setUTCHours(options.hour || 0);
Expand Down

0 comments on commit decdf87

Please sign in to comment.