Skip to content

Commit

Permalink
hotfix(hackernews): refactor timer
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 committed Dec 31, 2023
1 parent 9996c16 commit b83a9b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/hackernews.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ for (;;) {

if (now.getUTCHours() >= 11) {
// The next time is 00:00 AM
nextTime = new Date(`${now.getUTCFullYear()}-${(now.getUTCMonth() + 1).toString().padStart(2, "0")}-${(now.getUTCDate() + 1).toString().padStart(2, "0")}T00:00:00Z`);
const now = new Date();
now.setUTCHours(0, 0, 0, 0);
now.setUTCDate(now.getUTCDate() + 1);
nextTime = now;
} else if (now.getUTCHours() < 11) {
// The next time is 11:00 AM
nextTime = new Date(`${now.getUTCFullYear()}-${(now.getUTCMonth() + 1).toString().padStart(2, "0")}-${now.getUTCDate().toString().padStart(2, "0")}T11:00:00Z`);
const now = new Date();
now.setUTCHours(11, 0, 0, 0);
nextTime = now;
}

// eslint-disable-next-line no-await-in-loop
Expand Down

0 comments on commit b83a9b4

Please sign in to comment.