Skip to content

Commit

Permalink
fix: Last period Wto less than Wfrom
Browse files Browse the repository at this point in the history
  • Loading branch information
borjar20 committed Jan 14, 2022
1 parent 6f8bc6d commit 4917655
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,13 @@ module.exports.getLastPeriod = function getLastPeriod(from, to, period, Wto, rul
var dates = rruleSet.all();
}
dates[dates.length-1].setUTCHours(dates[dates.length-1].getUTCHours() + getTimeZoneOffset(dates[dates.length-1], timeZone));

let WFrom = dates[dates.length-1]

if( Wto < WFrom) Wto.setDate(WFrom.getDate() + 1)

return {
from: dates[dates.length-1].toISOString(),
from: WFrom.toISOString(),
to: Wto.toISOString()
};
}

0 comments on commit 4917655

Please sign in to comment.