generated from nhcarrigan/template
Reviewed-on: https://codeberg.org/nhcarrigan/tingle-bot/pulls/1 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
32 lines
783 B
TypeScript
32 lines
783 B
TypeScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import type { Season } from "../../interfaces/weather/names/season.js";
|
|
|
|
/**
|
|
* Module to get the season based on today's date.
|
|
* Winter: Dec 21 - March 20.
|
|
* Spring: March 21 - June 20.
|
|
* Summer: June 21st - September 22.
|
|
* Fall: September 23 - December 21.
|
|
* @returns The season name.
|
|
*/
|
|
export const getSeason = (): Season => {
|
|
const date = new Date();
|
|
const month = date.getMonth();
|
|
const day = date.getDate();
|
|
|
|
if (month < 2 || month === 2 && day < 21 || month === 11 && day > 20) {
|
|
return "Winter";
|
|
}
|
|
if (month < 5 || month === 5 && day < 21) {
|
|
return "Spring";
|
|
}
|
|
if (month < 8 || month === 8 && day < 23) {
|
|
return "Summer";
|
|
}
|
|
return "Fall";
|
|
};
|