Skip to content

Commit

Permalink
i hate working with dates
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhohk authored Nov 17, 2023
1 parent fa10157 commit 85a2ee3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function init() {
let monthDiff = (tday.getMonth()+1) - (date.getMonth()+1);
let dayDiff = tday.getDate() - date.getDate();
if (dayDiff < 0) {
dayDiff += daysInMonth(tday.getFullYear(), (tday.getMonth()+1)-1);
const carryMonth = ((tday.getMonth()+1)-1 === 0) ? 12 : (tday.getMonth()+1)-1;
dayDiff += daysInMonth(tday.getFullYear(), carryMonth);
monthDiff--;
}
if (monthDiff < 0) {
Expand Down

0 comments on commit 85a2ee3

Please sign in to comment.