Skip to content

Commit

Permalink
use date-fns
Browse files Browse the repository at this point in the history
  • Loading branch information
horrible-little-slime committed Oct 31, 2023
1 parent a0742ca commit ea6fd76
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/subs.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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() {
Expand Down

0 comments on commit ea6fd76

Please sign in to comment.