Time #112

Parent #1Owner #361Flags readSource hellcore/hellcore.db

Aliases: Time

15 verbs · 20 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
timethis none thisrxd#1128
ctimethis none thisrxd#11211
_heartbeatthis none thisrxd#1124
day_segmentthis none thisrxd#11216
is_later_than is_earlier_thanthis none thisrxd#1127
short_durationthis none thisrxd#11210
ctime_shortthis none thisrxd#11224
durationthis none thisrxd#11217
game_durationthis none thisrxd#1123
holiday_todaythis none thisrxd#1128
day_minutesthis none thisrxd#1125
ampmthis none thisrxd#11218
monththis none thisrxd#1124
moon_phasethis none thisrxd#11225
day_segment_namedthis none thisrxd#1121

Properties

PropertyDefinerFlagsOwnerValue
heartbeat_interval#112rc#361450
heartbeat_task#112rc#3610
help_msg#112rc#361
list of 5{"Game time runs 8 times faster than realtime -- for each real-life day, 8 days will pass in the game.", "", "$time:time() -> Return seconds-since-epoch.", "$time:ctime() -> Return string description of the current time or a given seconds-since-epoch time.", "$time:day_segment() -> Return current day segment (dawn/morning/day/evening/dusk/night) for room descriptions and other purposes."}
day_segments#112rc#361{"dawn", "morning", "day", "evening", "dusk", "night"}
holidays#112rc#361
list of 8{{"Xmas eve", "Dec 24"}, {"Xmas day", "Dec 25"}, {"New Year's eve", "Dec 31"}, {"New Year's day", "Jan 1"}, {"Suicide Day", "May 1"}, {"Armageddon Day", "Sep 11"}, {"Abortion Day", "Aug 18"}, {"Feast of all Clones", "Feb 21"}}
generic_holiday#112rc#361#122240
months#112rc#361
list of 12{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
months_short#112rc#361
list of 12{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
moon_phases#112rc#361
list of 8{{4, "full", "The full moon shines down brightly."}, {7, "waning gibbous", "The waning gibbous moon shines down."}, {10, "last quarter", "The last quarter moon shines in the night sky."}, {13, "waning crescent", "A sliver of waning crescent moon hangs in the night sky."}, {17, "new", "The black disc of the new moon hangs like a hole in the night sky."}, {20, "waxing crescent", "A sliver of waxing crescent moon hangs in the night sky."}, {25, "first quarter", "The first quarter moon shines in the night sky."}, {30, "waxing gibbous", "The waxing gibbous moon shines brightly in the night sky."}}
offset#112rc#3610
aliases#1rc#361{"Time"}
description#1rc#361"A utility object that keeps track of game time."
object_size#1r#29{10538, 1298433815}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #1 root

Children: none

Call graph

calls n112_1 #112:ctime n112_0 #112:time n112_1->n112_0 n112_2 #112:_heartbeat n112_2->n112_2 n112_3 #112:day_segment n112_3->n112_1 n112_3->n112_0 n112_4 #112:is_later_than n112_4->n112_1 n112_6 #112:ctime_short n112_6->n112_0 n112_8 #112:game_duration n112_7 #112:duration n112_8->n112_7 n112_9 #112:holiday_today n112_9->n112_1 n45_23 #45:leaves n112_9->n45_23 n112_10 #112:day_minutes n112_10->n112_1 n112_12 #112:month n112_12->n112_1 n112_12->n112_0 n112_13 #112:moon_phase n112_13->n112_1 n18_13 #18:mod n112_13->n18_13 n112_14 #112:day_segment_named n112_14->n112_3

Source

time

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1":time()";
2"Return INT number of game-seconds since epoch.";
3if (args)
4time = args[1];
5else
6time = time();
7endif
8return ((time - 1200000000) * 8) + this.offset;

ctime

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1":ctime([INT time])";
2"Return string describing the time.";
3time = args ? args[1] | this:time();
4ctime = ctime(time);
5"century = toint(ctime[21..22]);";
6"century = century + 1;";
7"ctime[21..22] = tostr(century);";
8year = toint(ctime[21..24]);
9year = year + 152;
10ctime[21..24] = tostr(year);
11return ctime[1..24];

_heartbeat

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1fork task_id (this.heartbeat_interval)
2this:_heartbeat();
3endfork
4this.heartbeat_task = task_id;

day_segment

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1":day_segment([INT time])";
2"Return ordinal day segment, for room descriptions and other purposes.";
3"1=dawn, 2=morning, 3=day, 4=evening, 5=dusk, 6=night";
4time = args ? args[1] | this:time();
5hour = toint((ctime = this:ctime(time))[12..13]);
6month = ctime[5..7] in this.months_short;
7if (hour < 10)
8morning = {-2, -1, 0, 0, 0, 1, 1, 1, 0, 0, -1, -1}[month];
9hour = hour + morning;
10elseif (hour > 12)
11evening = {2, 1, 0, 0, -1, -2, -2, 1, 0, 0, 1, 1}[month];
12hour = hour + evening;
13endif
14hour = hour + 1;
15hour = max(1, min(hour, 24));
16return {6, 6, 6, 6, 6, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6}[hour];

is_later_than is_earlier_than

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

none

Source

1":is_later_than(STR time)";
2"Given a string of the form hh:mm, return number-of-seconds-later if the current time is later than that.";
3dtime = args[1];
4dtimei = (toint(args[1][1..2]) * 60) + toint(args[1][4..5]);
5now = this:ctime();
6nowi = (toint(now[12..13]) * 60) + toint(now[15..16]);
7return (verb[4] == "l") ? max(0, nowi - dtimei) | max(0, dtimei - nowi);

short_duration

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1sec = args[1];
2if (sec < 60)
3return tostr(sec) + "s";
4elseif (sec < (60 * 60))
5return tostr(sec / 60) + "m";
6elseif (sec < ((60 * 60) * 24))
7return tostr(sec / (60 * 60)) + "h";
8else
9return tostr(sec / ((60 * 60) * 24)) + "d";
10endif

ctime_short

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1":ctime([INT time])";
2"Return string describing the time.";
3time = args ? args[1] | this:time();
4ctime = ctime(time);
5ctime = ctime[12..16];
6hour = toint(ctime[1..2]);
7min = ctime[4..5];
8if (hour > 12)
9hour = hour - 12;
10ampm = "pm";
11elseif (hour == 12)
12ampm = "pm";
13else
14ampm = "am";
15endif
16if (hour == 0)
17hour = 12;
18endif
19ctime = ($ansi.bold_on + $ansi.white) + tostr(hour);
20ctime = ctime + ":";
21ctime = ((ctime + $ansi.white) + $ansi.bold_on) + min;
22ctime = (ctime + $ansi.bold_off) + ampm;
23ctime = ctime + $ansi.reset;
24return ctime;

duration

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1{sec, ?long = 0} = args;
2if (sec < 60)
3s = (sec > 1) ? "s" | "";
4return (tostr(sec) + (long ? " second" | " sec")) + s;
5elseif (sec < (60 * 60))
6m = sec / 60;
7s = (m > 1) ? "s" | "";
8return (tostr(m) + (long ? " minute" | " min")) + s;
9elseif (sec < ((60 * 60) * 24))
10h = sec / (60 * 60);
11s = (h > 1) ? "s" | "";
12return (tostr(h) + (long ? " hour" | " hr")) + s;
13else
14d = sec / ((60 * 60) * 24);
15s = (d > 1) ? "s" | "";
16return (tostr(d) + " day") + s;
17endif

game_duration

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1"Text desc of how long 'duration' is in game-time, assuming 'duration' is real-time seconds.";
2dur = args[1];
3return this:duration(dur * 8);

holiday_today

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1ctime = args ? args[1] | this:ctime();
2cday = ctime[5..10];
3for x in ($ou:leaves(this.generic_holiday))
4if (x.day == cday)
5return x;
6endif
7endfor
8return #-1;

day_minutes

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

none

Source

1"Return number of minutes passed in this game day so far.";
2time = args ? args[1] | this:ctime()[12..16];
3hour = tonum(time[1..2]);
4min = tonum(time[4..5]);
5return (hour * 60) + min;

ampm

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

none

Source

1ct = args[1];
2hours = tonum(ct[1..2]);
3min = tonum(ct[4..5]);
4if (hours < 12)
5ap = "am";
6if (hours < 1)
7hours = 12;
8endif
9else
10ap = "pm";
11if (hours > 12)
12hours = hours - 12;
13endif
14endif
15if (min < 10)
16min = "0" + tostr(min);
17endif
18return ((tostr(hours) + ":") + tostr(min)) + ap;

month

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

none

Source

1time = args ? args[1] | this:time();
2ctime = this:ctime(time)[5..7];
3ctime = ctime in {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
4return ctime;

moon_phase

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

Source

1return_type = args ? args[1] | 1;
2ctime = $time:ctime();
3year = toint(ctime[23..24]);
4a1 = year % 19;
5if (a1 > 9)
6a1 = a1 - 9;
7endif
8a2 = $au:mod(a1 * 11, 30);
9day = toint(ctime[9..10]);
10phase = a2 + day;
11month = ctime[5..7] in this.months_short;
12if (month < 3)
13month = month + 2;
14endif
15phase = (phase + month) - 4;
16phase = phase % 30;
17if (return_type == 1)
18return phase;
19else
20for x in (this.moon_phases)
21if (phase <= x[1])
22return x[return_type];
23endif
24endfor
25endif

day_segment_named

Spec this none thisFlags rxdOwner #361Definer #112

Referenced by

none

Source

1return this.day_segments[this:day_segment()];