Skip to content

Commit e921cbc

Browse files
committed
fix: make next vote date inclusive of today
Normalize the current date to 00:00 so the comparison is day based. This should have said "Jan 30": publiccodeyml/publiccode.yml#288 (comment)
1 parent c798669 commit e921cbc

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

dist/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8972,12 +8972,14 @@ exports.reactToComment = reactToComment;
89728972
function getNextVoteDate() {
89738973
const now = new Date();
89748974
const year = now.getFullYear();
8975+
// Today at 00:00. We compare dates (not times).
8976+
const today = new Date(year, now.getMonth(), now.getDate());
89758977
const schedule = [
89768978
new Date(year, 0 /* Jan */, 30),
89778979
new Date(year, 4 /* May */, 30),
89788980
new Date(year, 8 /* Sep */, 30),
89798981
];
8980-
const next = schedule.find(d => d > now);
8982+
const next = schedule.find(d => d > today);
89818983
const nextDate = next !== null && next !== void 0 ? next : new Date(year + 1, schedule[0].getMonth(), schedule[0].getDate());
89828984
return nextDate.toLocaleDateString('en-US', {
89838985
month: 'long',

src/bot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ function getNextVoteDate() {
6767
const now = new Date();
6868
const year = now.getFullYear();
6969

70+
// Today at 00:00. We compare dates (not times).
71+
const today = new Date(year, now.getMonth(), now.getDate())
72+
7073
const schedule = [
7174
new Date(year, 0 /* Jan */, 30),
7275
new Date(year, 4 /* May */, 30),
7376
new Date(year, 8 /* Sep */, 30),
7477
];
7578

76-
const next = schedule.find(d => d > now);
79+
const next = schedule.find(d => d > today);
7780
const nextDate = next ?? new Date(year + 1, schedule[0]!.getMonth(), schedule[0]!.getDate());
7881

7982
return nextDate.toLocaleDateString('en-US', {

0 commit comments

Comments
 (0)