Skip to content

Commit

Permalink
stopatyearend param quick fix (slothpixel#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
camnwalter authored and ChristianDobbie committed Jan 10, 2022
1 parent ba2ff84 commit 6e4e1e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions store/buildSkyblockCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const eventTimes = {
},
};

function buildSkyblockCalendar(events, from, to, years, stopAtYearEnd = 'false') {
function buildSkyblockCalendar(events, from, to, years, stopAtYearEnd = false) {
const now = Date.now();
let fromDate = from || now;

Expand Down Expand Up @@ -237,7 +237,10 @@ function buildSkyblockCalendar(events, from, to, years, stopAtYearEnd = 'false')

if (toToYears <= 0) throw new Error("Parameter 'years' must be positive");

if (stopAtYearEnd === 'false') toToYears++;
// convert string to boolean
const stopBoolean = JSON.parse(stopAtYearEnd);

if (!stopBoolean) toToYears++;

for (let i = 0; i < toToYears; i++) {
for (const [event, { name, times: times_ }] of Object.entries(eventTimes)) {
Expand All @@ -253,7 +256,7 @@ function buildSkyblockCalendar(events, from, to, years, stopAtYearEnd = 'false')
};

/* eslint-disable-next-line no-continue */
if (stopAtYearEnd === 'true' && times.end < currentOffset) continue;
if (stopBoolean && times.end < currentOffset) continue;

const msTill = times.end < currentOffset
? yearMs - currentOffset + times.start
Expand Down

0 comments on commit 6e4e1e3

Please sign in to comment.