mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Thanks to PJB3005 cl experimental: SDQL2 has been refactored to a datum! rscadd: A new SDQL2 panel has been added to admin tabs, for tracking, VVing, and halting SDQL2 queries. rscadd: SDQL2 documentation is now available in SDQL_2.dm rscadd: SDQL2 now has MAP added. MAP will cause the query to execute on whatever is specified in MAP, whether it's a variable or a procedure call (which will grab the return results), etc etc. rscadd: SDQL2 now has a superuser mode, for uses outside of admin button pressing. This causes it to operate without admin protection wrapping. rscadd: SDQL2 now supports options, including ignoring nulls in select or forcing it to operate in high priority mode, which lets it use 95% of the tick instead of obeying the Master Controller's tick limit. USE WITH CAUTION. Also includes a mode for blocking proccalls rscadd: SDQL2 now supports TRUE/FALSE. rscadd: To use options, append OPTIONS to the query. Available are "PRIORITY" = HIGH/NORMAL, "SELECT" = FORCE_NULLS/DISABLE or 0/FALSE, "PROCCALL" = ASYNC/BLOCKING. /cl Also displaytimetext is refactored.
92 lines
3.1 KiB
Plaintext
92 lines
3.1 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, format)
|
|
|
|
/proc/station_time(display_only = FALSE)
|
|
return ((((world.time - SSticker.round_start_time) * SSticker.station_time_rate_multiplier) + SSticker.gametime_offset) % 864000) - (display_only? GLOB.timezoneOffset : 0)
|
|
|
|
/proc/station_time_timestamp(format = "hh:mm:ss")
|
|
return time2text(station_time(TRUE), format)
|
|
|
|
/proc/station_time_debug(force_set)
|
|
if(isnum(force_set))
|
|
SSticker.gametime_offset = force_set
|
|
return
|
|
SSticker.gametime_offset = rand(0, 864000) //hours in day * minutes in hour * seconds in minute * deciseconds in second
|
|
if(prob(50))
|
|
SSticker.gametime_offset = FLOOR(SSticker.gametime_offset, 3600)
|
|
else
|
|
SSticker.gametime_offset = CEILING(SSticker.gametime_offset, 3600)
|
|
|
|
/* 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
|
|
|
|
//returns timestamp in a sql and a not-quite-compliant ISO 8601 friendly format
|
|
/proc/SQLtime(timevar)
|
|
return time2text(timevar || world.timeofday, "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
|
|
|
|
//Takes a value of time in deciseconds.
|
|
//Returns a text value of that number in hours, minutes, or seconds.
|
|
/proc/DisplayTimeText(time_value, round_seconds_to = 0.1)
|
|
var/second = FLOOR(time_value * 0.1, round_seconds_to)
|
|
if(!second)
|
|
return "right now"
|
|
if(second < 60)
|
|
return "[second] second[(second != 1)? "s":""]"
|
|
var/minute = FLOOR(second / 60, 1)
|
|
second = FLOOR(MODULUS(second, 60), round_seconds_to)
|
|
var/secondT
|
|
if(second)
|
|
secondT = " and [second] second[(second != 1)? "s":""]"
|
|
if(minute < 60)
|
|
return "[minute] minute[(minute != 1)? "s":""][secondT]"
|
|
var/hour = FLOOR(minute / 60, 1)
|
|
minute = MODULUS(minute, 60)
|
|
var/minuteT
|
|
if(minute)
|
|
minuteT = " and [minute] minute[(minute != 1)? "s":""]"
|
|
if(hour < 24)
|
|
return "[hour] hour[(hour != 1)? "s":""][minuteT][secondT]"
|
|
var/day = FLOOR(hour / 24, 1)
|
|
hour = MODULUS(hour, 24)
|
|
var/hourT
|
|
if(hour)
|
|
hourT = " and [hour] hour[(hour != 1)? "s":""]"
|
|
return "[day] day[(day != 1)? "s":""][hourT][minuteT][secondT]"
|