summaryrefslogtreecommitdiff
path: root/world/map/npc
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2011-08-25 16:14:49 -0700
committerBen Longbons <b.r.longbons@gmail.com>2011-08-25 16:14:49 -0700
commit8d2fe139a61ed2ad3cc89fdc569ce22daf41ba96 (patch)
tree9036d6d690464841549e74986c85c14146caadef /world/map/npc
parentab9e7f6386eac72d662eb66b1aee0d6e8c98f0d1 (diff)
downloadserverdata-8d2fe139a61ed2ad3cc89fdc569ce22daf41ba96.tar.gz
serverdata-8d2fe139a61ed2ad3cc89fdc569ce22daf41ba96.tar.bz2
serverdata-8d2fe139a61ed2ad3cc89fdc569ce22daf41ba96.tar.xz
serverdata-8d2fe139a61ed2ad3cc89fdc569ce22daf41ba96.zip
Add script function time_stamp, a replacement for gettimestr
Diffstat (limited to 'world/map/npc')
-rw-r--r--world/map/npc/functions/time.txt56
1 files changed, 56 insertions, 0 deletions
diff --git a/world/map/npc/functions/time.txt b/world/map/npc/functions/time.txt
new file mode 100644
index 00000000..2527b853
--- /dev/null
+++ b/world/map/npc/functions/time.txt
@@ -0,0 +1,56 @@
+// A replacement for gettimestr()
+// At some point this should be a builtin in the server
+// Should I allow formatting of times other than the current time?
+
+// Variables:
+// output @ts_date$ "yyyy-mm-dd"
+// output @ts_time$ "hh:mm:ss"
+
+function|script|time_stamp|{
+ // local variables
+ // if there is reasonable demand, these might be exported
+ // (that is what the builtin is likely to do)
+ set @ts_year, gettime(7);
+ set @ts_month, gettime(6);
+ set @ts_mday, gettime(5);
+ //set @ts_wday, gettime(4);
+ set @ts_hour, gettime(3);
+ set @ts_minute, gettime(2);
+ set @ts_second, gettime(1);
+
+ // locals used to generate leading zeroes
+ set @ts_month_pad$, "";
+ set @ts_mday_pad$, "";
+ set @ts_hour_pad$, "";
+ set @ts_minute_pad$, "";
+ set @ts_second_pad$, "";
+
+ if (@ts_month < 10)
+ set @ts_month_pad$, "0";
+ if (@ts_mday < 10)
+ set @ts_mday_pad$, "0";
+ if (@ts_hour < 10)
+ set @ts_hour_pad$, "0";
+ if (@ts_minute < 10)
+ set @ts_minute_pad$, "0";
+ if (@ts_second < 10)
+ set @ts_second_pad$, "0";
+
+ set @ts_date$, @ts_year + "-" + @ts_month_pad$ + @ts_month + "-" + @ts_mday_pad$ + @ts_mday;
+ set @ts_time$, @ts_hour_pad$ + @ts_hour + ":" + @ts_minute_pad$ + @ts_minute + ":" +@ts_second_pad$ + @ts_second;
+
+ // cleanup
+ set @ts_year, 0;
+ set @ts_month, 0;
+ set @ts_mday, 0;
+ set @ts_hour, 0;
+ set @ts_minute, 0;
+ set @ts_second, 0;
+ set @ts_month_pad$, "";
+ set @ts_mday_pad$, "";
+ set @ts_hour_pad$, "";
+ set @ts_minute_pad$, "";
+ set @ts_second_pad$, "";
+
+ return;
+}