Makes holidays span all timezones by default (#58673)

* Adds timezone support for regional holidays

Also adds timezones to Waitangi Day, ANZAC Day, US Independence Day and Bastille Day

* Makes holidays span all timezones by default

Changes April Fools, Halloween and Christmas to be the correct dates instead of a range, using three timezones to cover the correct range instead

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
cacogen
2021-04-30 10:46:32 +12:00
committed by GitHub
parent 4caa69a773
commit 0c5a968a83
3 changed files with 112 additions and 21 deletions

View File

@@ -153,20 +153,23 @@ SUBSYSTEM_DEF(events)
/datum/controller/subsystem/events/proc/getHoliday()
if(!CONFIG_GET(flag/allow_holidays))
return // Holiday stuff was not enabled in the config!
var/YYYY = text2num(time2text(world.timeofday, "YYYY")) // get the current year
var/MM = text2num(time2text(world.timeofday, "MM")) // get the current month
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
var/DDD = time2text(world.timeofday, "DDD") // get the current weekday
for(var/H in subtypesof(/datum/holiday))
var/datum/holiday/holiday = new H()
if(holiday.shouldCelebrate(DD, MM, YYYY, DDD))
holiday.celebrate()
if(!holidays)
holidays = list()
holidays[holiday.name] = holiday
else
var/delete_holiday = TRUE
for(var/timezone in holiday.timezones)
var/time_in_timezone = world.realtime + timezone HOURS
var/YYYY = text2num(time2text(time_in_timezone, "YYYY")) // get the current year
var/MM = text2num(time2text(time_in_timezone, "MM")) // get the current month
var/DD = text2num(time2text(time_in_timezone, "DD")) // get the current day
var/DDD = time2text(time_in_timezone, "DDD") // get the current weekday
if(holiday.shouldCelebrate(DD, MM, YYYY, DDD))
holiday.celebrate()
LAZYSET(holidays, holiday.name, holiday)
delete_holiday = FALSE
break
if(delete_holiday)
qdel(holiday)
if(holidays)