From ea6fd76da4c43603f0f373f8d45723281308052e Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Tue, 31 Oct 2023 15:33:27 -0400 Subject: [PATCH] use `date-fns` --- src/subs.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/subs.ts b/src/subs.ts index 40d1dd99..f7680b31 100644 --- a/src/subs.ts +++ b/src/subs.ts @@ -1,22 +1,9 @@ +import { format } from "date-fns"; import { ThreadAutoArchiveDuration, roleMention } from "discord.js"; import { discordClient } from "./clients/discord.js"; import { config } from "./config.js"; -const MONTHS = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -]; function determineIotmMonthYear() { const today = new Date(); const daysInMonth = new Date( @@ -26,11 +13,11 @@ function determineIotmMonthYear() { ).getDate(); const useNextMonth = today.getDate() / daysInMonth > 0.5; - const isNextYear = today.getMonth() === 11 && useNextMonth; - return `${MONTHS[(today.getMonth() + Number(useNextMonth)) % 12]} ${( - today.getFullYear() + Number(isNextYear) - ).toFixed(0)}`; + format( + new Date(today.getFullYear(), today.getMonth() + Number(useNextMonth)), + "LLLL y", + ); } export async function rollSubs() {