mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-14 17:45:02 +01:00
aa4dc56835
## About The Pull Request Removes Station-Time entirely Server Time is now NST (Nanotrasen Standard Time). SS13 takes place exactly 540 years in the future of the current day, so every second is 1 second in-game. Round Time is now PT (Pay-Time), how Nanotrasen keeps track of how long the current rotation of Employees has been working for. Telecomms uses NST due to its importance of being the communication to the blackbox. Autopsy report, clocks, scientific reports and requisitions use both timestamps due to them being more official documents that NT may need to know beyond just the current round (just for flavortext). Pretty much everything else (Det scanner, PDA, IC logs, Time-of-Death, AI law changes, Cyborg file downloading) uses PT PT <img width="305" height="217" alt="image" src="https://github.com/user-attachments/assets/cef73025-6292-4f9c-8565-197397bda2ca" /> <img width="168" height="59" alt="image" src="https://github.com/user-attachments/assets/a99db568-045d-45fc-8206-0d9a7b13c7d2" /> <img width="308" height="122" alt="image" src="https://github.com/user-attachments/assets/37ca6f17-8916-4af2-9c91-0f0707038ca5" /> https://github.com/user-attachments/assets/29445051-c98b-4af3-a657-812083aab91a Clock (Literate) <img width="748" height="292" alt="image" src="https://github.com/user-attachments/assets/c824e812-91b5-4737-858d-768336e9a7c4" /> Clock (Illiterate) <img width="446" height="94" alt="image" src="https://github.com/user-attachments/assets/90d5ea0d-eaff-4ced-aa31-ffdf0b4832a5" /> New paperwork time working properly <img width="311" height="190" alt="image" src="https://github.com/user-attachments/assets/6d048926-db61-4c91-893b-ce93e1ea7775" /> NST <img width="800" height="115" alt="image" src="https://github.com/user-attachments/assets/35ffde49-13c1-4ce7-ab24-858e48b608bd" /> <img width="1288" height="142" alt="image" src="https://github.com/user-attachments/assets/40c30d16-e0de-4efc-b460-9486eeb901d6" /> # Other changes 1. Circuit time checker will now get the value of the given input (Hour, Minute, Second) rather than the full dedisecond time converted into hour/minutes/seconds <img width="270" height="67" alt="image" src="https://github.com/user-attachments/assets/097440cc-1c45-447f-9976-18de7f9c722c" /> 2. Turns nightshift into a round event that'll last approximately 22 minutes 3. 12-hour pref (doesn't apply to the stat panel because it's global info) & removal of "TCT" time <img width="569" height="440" alt="image" src="https://github.com/user-attachments/assets/d39083b1-d248-41c0-9a1c-b2398ca203a7" /> 4. The chocolate pudding negative moodlet is now based on the server's IRL time. 5. Admins can now use ``class``, ``style`` and ``background`` (they were already given perms to use ``img`` so hiding background, which was removed to prevent image embedding, is pointless) 6. Also fixes ``year`` being off on localhost. ## Why It's Good For The Game Server Time is approximately 1s = 12s converted, not including it desyncing from lag (I believe?). This makes it pretty much impossible for people to actually use this as a unit of measurement for in-game actions. Different things also uses different timestamps which is a bit more confusing. The main change here is for accessibility and, hopefully, using time as a source of immersion. "20 minutes ago" is no longer OOC, they're just speaking in PT. There's no timezones in space, Nanotrasen Standard Time is the closest there is, but Pay Time is how NT considers when you get your paychecks, so it's what is more commonly used. It also fixes major inconsistencies between "IC time" and "Station time", things like breakfast moodlet was the first 15mins of the round despite the round starting like 7 hours in? Nukies with an L6 SAW firing down the halls was shooting like 1 bullet every 3 seconds (assuming 4 bullets per second), overall there was just a disconnect between how long time actually is in the universe. The secondary reason for this change (though it is what pushed me to actually get around to making this change) is the greater stat-panel removal. This hopes to lessen the dependence on the stat panel for station-time by making it easier to understand, and the end-goal I have is for this information to be limited to Admins & the AI (AI will get the IC version with the accurate year), so until that happens I would like to improve the use of station-time by making it consistent (for example, you should only care for PT for IC, which is also what your PDA displays), so that when it gets removed it won't leave players timeless. If you haven't already, and is interested in helping remove the stat panel, every entry that needs to be removed can be found here - https://hackmd.io/443_dE5lRWeEAp9bjGcKYw?view Closes https://github.com/tgstation/tgstation/issues/94988 ## Changelog 🆑 del: Removed Station Time, now we use NST (Nanotrasen Standard Time), which is IRL server time +540 years, and PT (Pay Time), the amount of time since the round has started. del: Station nightshift is now a Station event rather than being based on Server time. balance: Time circuit's Unit of Measure now tells the amount of time in hour/minute/seconds rather than giving the whole time translated to hours/minutes/seconds. qol: Added a 12-hour clock pref for people who prefer it. qol: Hovering over NST timestamps on official documents will now translate how much it is in PT/Shift Time. admin: Admins can now use style/class/background in their papercode. /🆑 --------- Co-authored-by: Isratosh <Isratosh@hotmail.com>
126 lines
4.5 KiB
Plaintext
126 lines
4.5 KiB
Plaintext
/// Returns UTC timestamp with the specifified format, with optionally deciseconds or optional IC time (year offset), AKA Nanotrasen Standard Time (NST)
|
|
/proc/server_timestamp(format = "hh:mm:ss", show_ds, ic_time, twelve_hour_clock)
|
|
var/time_string = twelve_hour_clock ? time_to_twelve_hour(format, world.timeofday, world.timezone) : time2text(world.timeofday, format, world.timezone)
|
|
if(ic_time && findtext(format, "YYYY")) //if we have a year, replace the year
|
|
time_string = replacetext_char(time_string, "[GLOB.year_integer]", CURRENT_STATION_YEAR)
|
|
return show_ds ? "[time_string]:[world.timeofday % 10]" : time_string
|
|
|
|
/// Returns timestamp since the round started, AKA Pay Time (PT)
|
|
/proc/round_timestamp(format = "hh:mm:ss", wtime = STATION_TIME_PASSED())
|
|
return time2text(wtime, format, NO_TIMEZONE)
|
|
|
|
///returns timestamp in a sql and a not-quite-compliant ISO 8601 friendly format. Do not use for SQL, use NOW() instead
|
|
/proc/ISOtime(timevar)
|
|
return time2text(timevar || world.timeofday, "YYYY-MM-DD hh:mm:ss", world.timezone)
|
|
|
|
|
|
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!
|
|
GLOB.midnight_rollovers++
|
|
GLOB.rollovercheck_last_timeofday = world.timeofday
|
|
return GLOB.midnight_rollovers
|
|
|
|
|
|
///Returns a string day as an integer in ISO format 1 (Monday) - 7 (Sunday)
|
|
/proc/weekday_to_iso(ddd)
|
|
switch (ddd)
|
|
if (MONDAY)
|
|
return 1
|
|
if (TUESDAY)
|
|
return 2
|
|
if (WEDNESDAY)
|
|
return 3
|
|
if (THURSDAY)
|
|
return 4
|
|
if (FRIDAY)
|
|
return 5
|
|
if (SATURDAY)
|
|
return 6
|
|
if (SUNDAY)
|
|
return 7
|
|
|
|
///Returns an integer in ISO format 1 (Monday) - 7 (Sunday) as a string day
|
|
/proc/iso_to_weekday(ddd)
|
|
switch (ddd)
|
|
if (1)
|
|
return MONDAY
|
|
if (2)
|
|
return TUESDAY
|
|
if (3)
|
|
return WEDNESDAY
|
|
if (4)
|
|
return THURSDAY
|
|
if (5)
|
|
return FRIDAY
|
|
if (6)
|
|
return SATURDAY
|
|
if (7)
|
|
return SUNDAY
|
|
|
|
/// Returns the day (mon, tues, wen...) in number format, 1 (monday) - 7 (sunday) from the passed in date (year, month, day)
|
|
/// All inputs are expected indexed at 1
|
|
/proc/day_of_month(year, month, day)
|
|
// https://en.wikipedia.org/wiki/Zeller%27s_congruence
|
|
var/m = month < 3 ? month + 12 : month // month (march = 3, april = 4...february = 14)
|
|
var/K = year % 100 // year of century
|
|
var/J = round(year / 100) // zero-based century
|
|
// day 0-6 saturday to friday:
|
|
var/h = (day + round(13 * (m + 1) / 5) + K + round(K / 4) + round(J / 4) - 2 * J) % 7
|
|
//convert to ISO 1-7 monday first format
|
|
return ((h + 5) % 7) + 1
|
|
|
|
/proc/first_day_of_month(year, month)
|
|
return day_of_month(year, month, 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]"
|
|
|
|
|
|
/proc/daysSince(realtimev)
|
|
return round((world.realtime - realtimev) / (24 HOURS))
|
|
|
|
/**
|
|
* Converts a time expressed in deciseconds (like world.time) to the 12-hour time format.
|
|
* the format arg is the format passed down to time2text() (e.g. "hh:mm" is hours and minutes but not seconds).
|
|
* the timezone is the time value offset from the local time. It's to be applied outside time2text() to get the AM/PM right.
|
|
*/
|
|
/proc/time_to_twelve_hour(format = "hh:mm:ss", time = STATION_TIME_PASSED(), timezone = NO_TIMEZONE)
|
|
time = MODULUS(time + (timezone * (1 HOURS)), 24 HOURS)
|
|
var/am_pm = "AM"
|
|
if(time > 12 HOURS)
|
|
am_pm = "PM"
|
|
if(time > 13 HOURS)
|
|
time -= 12 HOURS // e.g. 4:16 PM but not 00:42 PM
|
|
else if (time < 1 HOURS)
|
|
time += 12 HOURS // e.g. 12.23 AM
|
|
//set NO_TIMEZONE because we've already applied the timezone above.
|
|
return "[time2text(time, format, NO_TIMEZONE)] [am_pm]"
|