#pragma once

enumflags SEASONFLAG:int {
	WINTER 		= 0x0001,
	CHRISTMAS 	= 0x0002,
	AUTUMN 		= 0x0004,
	HALLOWEEN 	= 0x0008,
	SUMMER 		= 0x0010,
	JULY4TH 	= 0x0020,
	SPRING 		= 0x0040,
	EASTER 		= 0x0080,
};

void Seasonal_TimeOfDay(int is_local, int *day, int *month, int *year)
{
	string date_string = strftime(is_local, "%Y/%m/%d");
	tokenizebyseparator(date_string, "/");

	if (year)
		*year = stoi(argv(0));
	if (month)
		*month = stoi(argv(1));
	if (day)
		*day = stoi(argv(2));
}

#ifdef SSQC
var int season_flags = 0x0;
var int timeofday_day = 0;
var int timeofday_month = 0;
var int timeofday_year = 0;

void Seasonal_UpdateFlags(void)
{
	Seasonal_TimeOfDay(FALSE, &timeofday_day, &timeofday_month, &timeofday_year);
	season_flags = 0x0;

	// christmas
	if ((timeofday_month == 12 && timeofday_day >= 21) || (timeofday_month == 1 && timeofday_day <= 14))
		season_flags |= SEASONFLAG::CHRISTMAS;

	// halloween
	if ((timeofday_month == 10 && timeofday_day >= 22) || (timeofday_month == 11 && timeofday_day <= 5))
		season_flags |= SEASONFLAG::HALLOWEEN;

	// 4th of july
	if ((timeofday_month == 7 && timeofday_day >= 1) || (timeofday_month == 7 && timeofday_day <= 5))
		season_flags |= SEASONFLAG::JULY4TH;

	// spring
	if ((timeofday_month == 3 && timeofday_day >= 20) || (timeofday_month == 6 && timeofday_day < 20) || (timeofday_month == 4 || timeofday_month == 5))
		season_flags |= SEASONFLAG::SPRING;
	// summer
	else if ((timeofday_month == 6 && timeofday_day >= 20) || (timeofday_month == 9 && timeofday_day < 20) || (timeofday_month == 7 || timeofday_month == 8))
		season_flags |= SEASONFLAG::SUMMER;
	// autumn
	else if ((timeofday_month == 9 && timeofday_day >= 20) || (timeofday_month == 12 && timeofday_day < 20) || (timeofday_month == 10 || timeofday_month == 11))
		season_flags |= SEASONFLAG::AUTUMN;
	// winter
	else if ((timeofday_month == 12 && timeofday_day >= 20) || (timeofday_month == 3 && timeofday_day < 20) || (timeofday_month == 1 || timeofday_month == 2))
		season_flags |= SEASONFLAG::WINTER;
}
#else
#define season_flags (getstati(STAT_SEASONALFLAGS))
#endif