Skip to content

Commit

Permalink
Merge pull request #211 from teknologi-umum/hotfix/hackernews-timer
Browse files Browse the repository at this point in the history
hotfix(hackernews): refactor timer
elianiva authored Dec 31, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9996c16 + b83a9b4 commit 3f85d42
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
@@ -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

0 comments on commit 3f85d42

Please sign in to comment.