blob: 87d650d73ad81434c1e2ed7a839cae08375e8abc [file] [log] [blame]
PineaFane69bd222022-12-04 22:18:20 +00001function getSeason() {
2 let year = new Date().getFullYear();
3
4 const dates = {
5 pride: [new Date(`${year}-6-1`), new Date(`${year}-6-31`)],
6 halloween: [new Date(`${year}-10-25`), new Date(`${year}-11-1`)],
7 trans: [new Date(`${year}-11-13`), new Date(`${year}-11-19`)],
8 christmas: [new Date(`${year}-12-1`), new Date(`${year}-12-26`)]
9 }
10 const filePaths = {
11 normal: "normal",
12 halloween: "seasonal/halloween",
13 christmas: "seasonal/christmas",
14 pride: "seasonal/pride",
15 trans: "seasonal/trans"
16 }
17
18 let current = new Date();
19 let currentSeason = Object.keys(dates).find((str) => current >= dates[str][0] && current <= dates[str][1]) || "normal";
20
21 return {
22 season: currentSeason,
23 filePath: filePaths[currentSeason]
24 }
25}
26
27const Season = async (req, res) => {
28 return res.status(200).send(getSeason());
29}
30
31export default Season;
32export { getSeason };