Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds fluff calendars #7047

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions code/__HELPERS/_time.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,140 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
if(hour)
hourT = " and [hour] hour[(hour != 1)? "s":""]"
return "[day] day[(day != 1)? "s":""][hourT][minuteT][secondT]"

/*

Days of the week to make it easier to reference them.

When using time2text(), please use "DDD" to find the weekday. Refrain from using "Day"

*/
#define MONDAY "Mon"
#define TUESDAY "Tue"
#define WEDNESDAY "Wed"
#define THURSDAY "Thu"
#define FRIDAY "Fri"
#define SATURDAY "Sat"
#define SUNDAY "Sun"

//Months

#define JANUARY 1
#define FEBRUARY 2
#define MARCH 3
#define APRIL 4
#define MAY 5
#define JUNE 6
#define JULY 7
#define AUGUST 8
#define SEPTEMBER 9
#define OCTOBER 10
#define NOVEMBER 11
#define DECEMBER 12

//Select holiday names -- If you test for a holiday in the code, make the holiday's name a define and test for that instead
#define NEW_YEAR "New Year"
#define VALENTINES "Valentine's Day"
#define APRIL_FOOLS "April Fool's Day"
#define ST_PATRICK "Saint Patrick's Day"

#define EASTER "Easter"
#define HALLOWEEN "Halloween"
#define CHRISTMAS "Christmas"
#define FESTIVE_SEASON "Festive Season"
#define HOTDOG_DAY "National Hot Dog Day"

/*Timezones*/

/// Line Islands Time
#define TIMEZONE_LINT 14

// Chatham Daylight Time
#define TIMEZONE_CHADT 13.75

/// Tokelau Time
#define TIMEZONE_TKT 13

/// Tonga Time
#define TIMEZONE_TOT 13

/// New Zealand Daylight Time
#define TIMEZONE_NZDT 13

/// New Zealand Standard Time
#define TIMEZONE_NZST 12

/// Norfolk Time
#define TIMEZONE_NFT 11

/// Lord Howe Standard Time
#define TIMEZONE_LHST 10.5

/// Australian Eastern Standard Time
#define TIMEZONE_AEST 10

/// Australian Central Standard Time
#define TIMEZONE_ACST 9.5

/// Australian Central Western Standard Time
#define TIMEZONE_ACWST 8.75

/// Australian Western Standard Time
#define TIMEZONE_AWST 8

/// Christmas Island Time
#define TIMEZONE_CXT 7

/// Cocos Islands Time
#define TIMEZONE_CCT 6.5

/// Central European Summer Time
#define TIMEZONE_CEST 2

/// Coordinated Universal Time
#define TIMEZONE_UTC 0

/// Eastern Daylight Time
#define TIMEZONE_EDT -4

/// Eastern Standard Time
#define TIMEZONE_EST -5

/// Central Daylight Time
#define TIMEZONE_CDT -5

/// Central Standard Time
#define TIMEZONE_CST -6

/// Mountain Daylight Time
#define TIMEZONE_MDT -6

/// Mountain Standard Time
#define TIMEZONE_MST -7

/// Pacific Daylight Time
#define TIMEZONE_PDT -7

/// Pacific Standard Time
#define TIMEZONE_PST -8

/// Alaska Daylight Time
#define TIMEZONE_AKDT -8

/// Alaska Standard Time
#define TIMEZONE_AKST -9

/// Hawaii-Aleutian Daylight Time
#define TIMEZONE_HDT -9

/// Hawaii Standard Time
#define TIMEZONE_HST -10

/// Cook Island Time
#define TIMEZONE_CKT -10

/// Niue Time
#define TIMEZONE_NUT -11

/// Anywhere on Earth
#define TIMEZONE_ANYWHERE_ON_EARTH -12
41 changes: 41 additions & 0 deletions code/__HELPERS/dates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//Adapted from a free algorithm written in BASIC (https://www.assa.org.au/edm#Computer)
/proc/EasterDate(y)
var/FirstDig, Remain19, temp //Intermediate Results
var/tA, tB, tC, tD, tE //Table A-E results
var/d, m //Day and Month returned

FirstDig = round((y / 100))
Remain19 = y % 19

temp = (round((FirstDig - 15) / 2)) + 202 - 11 * Remain19

switch(FirstDig)
if(21,24,25,27,28,29,30,31,32,34,35,38)
temp -= 1
if(33,36,37,39,40)
temp -= 2
temp %= 30

tA = temp + 21
if(temp == 29)
tA -= 1
if(temp == 28 && (Remain19 > 10))
tA -= 1
tB = (tA - 19) % 7

tC = (40 - FirstDig) % 4
if(tC == 3)
tC += 1
if(tC > 1)
tC += 1
temp = y % 100
tD = (temp + round((temp / 4))) % 7

tE = ((20 - tB - tC - tD) % 7) + 1
d = tA + tE
if(d > 31)
d -= 31
m = 4
else
m = 3
return list("day" = d, "month" = m)
40 changes: 40 additions & 0 deletions code/controllers/subsystem/events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SUBSYSTEM_DEF(events)
if(!E.typepath)
continue //don't want this one! leave it for the garbage collector
control += E //add it to the list of all events (controls)
if(isnull(GLOB.holidays))
fill_holidays()
reschedule()
return SS_INIT_SUCCESS

Expand Down Expand Up @@ -128,3 +130,41 @@ SUBSYSTEM_DEF(events)
SSevents.can_fire = !SSevents.can_fire
message_admins("[usr.client] has toggled the events subsystem [SSevents.can_fire == 1 ? "on" : "off"]")
log_admin("[usr.client] has toggled the events subsystem [SSevents.can_fire == 1 ? "on" : "off"]")

GLOBAL_LIST(holidays)

/**
* Checks that the passed holiday is located in the global holidays list.
*
* Returns a holiday datum, or null if it's not that holiday.
*/
/proc/check_holidays(holiday_to_find)
if(isnull(GLOB.holidays) && !fill_holidays())
return // Failed to generate holidays, for some reason

return GLOB.holidays[holiday_to_find]

/**
* Fills the holidays list if applicable, or leaves it an empty list.
*/
/proc/fill_holidays()
GLOB.holidays = list()
for(var/holiday_type in subtypesof(/datum/holiday))
var/datum/holiday/holiday = new holiday_type()
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))
GLOB.holidays[holiday.name] = holiday
delete_holiday = FALSE
break
if(delete_holiday)
qdel(holiday)

return TRUE
43 changes: 43 additions & 0 deletions code/game/objects/structures/signs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,46 @@
desc = "An unbelievably creepy cat clock that surveys the room with every tick and every tock."
icon = 'icons/obj/structures/props/catclock.dmi'
icon_state = "cat_clock_motion"

//===================//
// Calendar //
//=================//

/obj/structure/sign/calendar
name = "wall calendar"
desc = "Classic office decoration and a place to stare at maniacally."
icon_state = "calendar_civ"
var/calendar_faction

/obj/structure/sign/calendar/get_examine_text(mob/user)
. = ..()
. += SPAN_INFO("The current date is: [time2text(world.realtime, "DDD, MMM DD")], [GLOB.game_year].")
if(length(GLOB.holidays))
. += SPAN_INFO("Events:")
for(var/holidayname in GLOB.holidays)
var/datum/holiday/holiday = GLOB.holidays[holidayname]
if(holiday.holiday_faction)
if(holiday.holiday_faction != calendar_faction)
continue
. += SPAN_INFO("[holiday.name]")
. += SPAN_BOLDNOTICE("[holiday.greet_text]")

/obj/structure/sign/calendar/upp
icon_state = "calendar_upp"
desc = "Classic office decoration and a place to stare at maniacally, has a UPP logo on it, also all text is in Russian."
Copy link
Contributor

@efzapa efzapa Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classic office decoration with a spot to stare at maniacally. Features a UPP logo, with all text in Russian.

grammar should be fixed here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

calendar_faction = FACTION_UPP

/obj/structure/sign/calendar/wy
icon_state = "calendar_wy"
desc = "Classic office decoration and a place to stare at maniacally, produced by Weyland-Yutani."
calendar_faction = FACTION_WY

/obj/structure/sign/calendar/twe
icon_state = "calendar_twe"
desc = "Classic office decoration and a place to stare at maniacally, has a pattern resembling a Union Jack on it."
calendar_faction = FACTION_TWE

/obj/structure/sign/calendar/ua
icon_state = "calendar_ua"
desc = "Classic office decoration and a place to stare at maniacally, has a vertically placed UA flag and some army symbolics."
calendar_faction = FACTION_MARINE
Loading
Loading