Fix date range negative month

This commit is contained in:
Jiang Yio 2025-01-02 22:52:19 -05:00
parent e648988b53
commit fcd8447658

View File

@ -53,8 +53,8 @@
} }
function timeshift_month(date, diff) { function timeshift_month(date, diff) {
var month = date.getMonth() + diff; var month = date.getMonth() + diff, month_mod12 = month%12;
return new Date(date.getFullYear() + Math.floor(month/12), month >= 0 ? (month%12) : (month%12 + 12), date.getDate()); return new Date(date.getFullYear() + Math.floor(month/12), month_mod12 >= 0 ? (month_mod12) : (month_mod12 + 12), date.getDate());
} }
function datecalc(date, range, direction) { function datecalc(date, range, direction) {