Skip to content

Commit 967eb7f

Browse files
committed
Use zonedNow
1 parent 8679469 commit 967eb7f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/commands/saufen.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type { ApplicationCommand, AutocompleteCommand } from "#commands/command.
1515
import type { BotContext } from "#context.ts";
1616
import { connectAndPlaySaufen } from "#handler/voiceHandler.ts";
1717
import assertNever from "#utils/assertNever.ts";
18+
import { zonedNow } from "#utils/dateUtils.ts";
1819

1920
type SubCommand = "los" | "add" | "list" | "select";
2021

@@ -65,15 +66,11 @@ export default class Saufen implements ApplicationCommand, AutocompleteCommand {
6566
}
6667

6768
const subCommand = command.options.getSubcommand() as SubCommand;
68-
const isWeekend = (): boolean => {
69-
const today = new Date();
70-
if (today.getDay() === 0 || today.getDay() === 6) {
71-
return true;
72-
}
73-
if (today.getDay() === 5 && today.getHours() > 18) {
74-
return true;
75-
}
76-
return false;
69+
const isWeekend = () => {
70+
const now = zonedNow();
71+
return (
72+
now.dayOfWeek === 6 || now.dayOfWeek === 7 || (now.dayOfWeek === 5 && now.hour > 18)
73+
);
7774
};
7875

7976
const reply = () => {

0 commit comments

Comments
 (0)