MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | #include <time.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 4 | int mktime(int *ts) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 5 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 6 | DESCRIPTION |
| 7 | If the argument <ts> is an array with 9 elements (int) according to |
| 8 | the result of localtime(), this function returns the number of seconds |
| 9 | passed since the epoch (00:00:00 UTC, January 1, 1970). |
| 10 | mktime() interprets the input data according to the current timezone |
| 11 | setting of the host system. |
| 12 | This can be used to store a date or time as an integer value or to |
| 13 | compute differences betweens two different dates or times. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 14 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 15 | The array <ts> has to have the following structure: |
| 16 | int TM_SEC (0): seconds (0..59) |
| 17 | int TM_MIN (1): minutes (0..59) |
| 18 | int TM_HOUR (2): hours (0..23) |
| 19 | int TM_MDAY (3): day of month (1..31) |
| 20 | int TM_MON (4): day of year (0..11) |
| 21 | int TM_YEAR (5): year (e.g. 2001) |
| 22 | int TM_WDAY (6): day of week (0..6, sunday = 0) |
| 23 | int TM_YDAY (7): day of year (0..365) |
| 24 | inz TM_ISDST (8): Daylight Saving Time (1,0,-1) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 25 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 26 | TM_YDAY and TM_WDAY are ignored and can contain arbitrary |
| 27 | integer values. |
| 28 | TM_ISDST can be 1 (daylight saving time in effect), 0 (DST not in |
| 29 | effect) or -1. A value of -1 causes the mktime() function to attempt |
| 30 | to divine whether daylight saving time is in effect for the specified |
| 31 | time. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 32 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 33 | EXAMPLES |
| 34 | A date and time (user input) shall be stored as unix timestamp: |
| 35 | // "Wed Oct 24 10:48:00 2007" corresponds to the returned time stamp: |
| 36 | int unixtime = mktime( ({0, 48, 09, 24, 09, 2007, 0, 01, 0}) ); |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 37 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 38 | HISTORY |
| 39 | Introduced in LDMud 3.3.718. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 40 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 41 | SEE ALSO |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 42 | ctime(E), gmtime(E), localtime(E), time(E), utime(E) |