Difference between revisions of "Manual:DIL Manual/asctime()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = asctime() = | |
| − | + | '''Function''' (string). Writes a time in seconds as a date, such as "Mon Nov 18 18:49:08 1996". | |
| − | |||
| − | + | asctime(t : integer) | |
| − | |||
| − | + | Converts <code>t</code>, a real-world time in seconds since 1 January 1970 (the value of | |
| − | + | [[Manual:DIL Manual/realtime|realtime]]), into a date and time in the server's time zone. It is | |
| + | the C library's <code>ctime()</code> without the newline at the end. | ||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| + | | t || integer || Seconds since 1 January 1970, usually <code>realtime</code> or a value saved from it. | ||
| + | |} | ||
| − | + | == Returns == | |
| − | + | String: <code>"Www Mmm dd hh:mm:ss yyyy"</code>, for instance <code>"Sat Nov 14 09:05:31 2026"</code>. | |
| + | It fails when the argument is a failed value. | ||
| − | + | == Notes == | |
| − | + | * '''Give it a variable or an expression, never a bare number.''' vmc compiles | |
| + | <code>asctime(0)</code> or <code>asctime(3600 * 24)</code> without its argument, and running | ||
| + | that stops the server. <code>asctime(realtime)</code>, <code>asctime(t)</code> or | ||
| + | <code>asctime(pc.birth)</code> are fine. | ||
| + | * DIL integers are 32 bits, so dates after January 2038 can't be shown. | ||
| + | * For the time in the game world use [[Manual:DIL Manual/mudhour()|mudhour()]], | ||
| + | [[Manual:DIL Manual/mudday()|mudday()]] and the like. | ||
| − | + | == Example == | |
| + | <pre> | ||
| + | dilbegin bug_note(pc : unitptr, txt : string); | ||
| + | var | ||
| + | i : integer; | ||
| + | code | ||
| + | { | ||
| + | i := flog("bugs", pc.name + " " + asctime(realtime) + ": " + txt + "<br/>", "a"); | ||
| + | sendtext("Thank you, it is noted.<br/>", pc); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Writes a player's report with the date and time into a log file, as the <code>bug</code> | ||
| + | command in commands.zon does. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/realtime|realtime]] | ||
| + | * [[Manual:DIL Manual/birth|birth]] | ||
| + | * [[Manual:DIL Manual/flog()|flog()]] | ||
| + | * [[Manual:DIL Manual/log()|log()]] | ||
Revision as of 23:20, 14 November 2026
asctime()
Function (string). Writes a time in seconds as a date, such as "Mon Nov 18 18:49:08 1996".
asctime(t : integer)
Converts t, a real-world time in seconds since 1 January 1970 (the value of
realtime), into a date and time in the server's time zone. It is
the C library's ctime() without the newline at the end.
Parameters
| Name | Type | Meaning |
|---|---|---|
| t | integer | Seconds since 1 January 1970, usually realtime or a value saved from it.
|
Returns
String: "Www Mmm dd hh:mm:ss yyyy", for instance "Sat Nov 14 09:05:31 2026".
It fails when the argument is a failed value.
Notes
- Give it a variable or an expression, never a bare number. vmc compiles
asctime(0)orasctime(3600 * 24)without its argument, and running that stops the server.asctime(realtime),asctime(t)orasctime(pc.birth)are fine.
- DIL integers are 32 bits, so dates after January 2038 can't be shown.
- For the time in the game world use mudhour(),
mudday() and the like.
Example
dilbegin bug_note(pc : unitptr, txt : string);
var
i : integer;
code
{
i := flog("bugs", pc.name + " " + asctime(realtime) + ": " + txt + "<br/>", "a");
sendtext("Thank you, it is noted.<br/>", pc);
quit;
}
dilend
Writes a player's report with the date and time into a log file, as the bug
command in commands.zon does.