Files
Yogstation/code/__HELPERS/time.dm
Really-Good-Soda-Flavor e48df5338c [READY] New holidays including Thanksgiving and Ramadan (#28054)
* New holidays and weekday helper

* Got rid of var/

* Added separate Thanksgivings and removed an indentation on Tuesday

* Makes Mother's Day less ambiguous.

* Adds Ramadan heck yea

* Gives Ramadan a fixer-upper so it is accurate for a good while
2017-06-23 16:24:28 -04:00

53 lines
1.6 KiB
Plaintext

//Returns the world time in english
/proc/worldtime2text()
return gameTimestamp("hh:mm:ss", world.time)
/proc/time_stamp(format = "hh:mm:ss", show_ds)
var/time_string = time2text(world.timeofday, format)
return show_ds ? "[time_string]:[world.timeofday % 10]" : time_string
/proc/gameTimestamp(format = "hh:mm:ss", wtime=null)
if(!wtime)
wtime = world.time
return time2text(wtime - GLOB.timezoneOffset + SSticker.gametime_offset - SSticker.round_start_time, format)
/* Returns 1 if it is the selected month and day */
/proc/isDay(month, day)
if(isnum(month) && isnum(day))
var/MM = text2num(time2text(world.timeofday, "MM")) // get the current month
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
if(month == MM && day == DD)
return 1
// Uncomment this out when debugging!
//else
//return 1
//returns timestamp in a sql and ISO 8601 friendly format
/proc/SQLtime(timevar)
if(!timevar)
timevar = world.realtime
return time2text(timevar, "YYYY-MM-DD hh:mm:ss")
GLOBAL_VAR_INIT(midnight_rollovers, 0)
GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
/proc/update_midnight_rollover()
if (world.timeofday < GLOB.rollovercheck_last_timeofday) //TIME IS GOING BACKWARDS!
return GLOB.midnight_rollovers++
return GLOB.midnight_rollovers
/proc/weekdayofthemonth()
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
switch(DD)
if(8 to 13)
return 2
if(14 to 20)
return 3
if(21 to 27)
return 4
if(28 to INFINITY)
return 5
else
return 1