Skip to content
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

Decrementing 'day' on Jan 1 results in NaN #7

Open
kastentx opened this issue Jan 3, 2020 · 1 comment · May be fixed by #8
Open

Decrementing 'day' on Jan 1 results in NaN #7

kastentx opened this issue Jan 3, 2020 · 1 comment · May be fixed by #8

Comments

@kastentx
Copy link

kastentx commented Jan 3, 2020

while (day < 1) {
month -= 1;
day = daysInMonth(year, month) - day;
if (month < 1) { month = 12; year -= 1; }

Issue arises when day and month are both 1, and the day is decremented by 1, e.g:

MyCivilDate.plus({ days: -1 })

This causes daysInMonth to be called with a month value of 0 which is then decremented by 1 to get the index, which fails.

@kastentx kastentx linked a pull request Jan 3, 2020 that will close this issue
@sosoba
Copy link

sosoba commented Jan 16, 2020

Is it correct to decrement year:

year -= 1;

without checking? Remember that gregorian callendar doees not has 0 year and 1 - 1 should be -1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants