1 /**
2  * D header file for C99.
3  *
4  * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_time.h.html, _time.h)
5  *
6  * Copyright: Copyright Sean Kelly 2005 - 2009.
7  * License: Distributed under the
8  *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
9  *    (See accompanying file LICENSE)
10  * Authors:   Sean Kelly,
11  *            Alex Rønne Petersen
12  * Source:    $(DRUNTIMESRC core/stdc/_time.d)
13  * Standards: ISO/IEC 9899:1999 (E)
14  */
15 
16 module core.sys.wasi.time;
17 
18 version (WASI):
19 
20 public import core.sys.wasi.types : time_t, clock_t, error_t;
21 
22 import core.stdc.config;
23 
24 extern (C):
25 @trusted: // There are only a few functions here that use unsafe C strings.
26 nothrow:
27 @nogc:
28 
29 ///
30 struct tm
31 {
32     int     tm_sec;     /// seconds after the minute [0-60]
33     int     tm_min;     /// minutes after the hour [0-59]
34     int     tm_hour;    /// hours since midnight [0-23]
35     int     tm_mday;    /// day of the month [1-31]
36     int     tm_mon;     /// months since January [0-11]
37     int     tm_year;    /// years since 1900
38     int     tm_wday;    /// days since Sunday [0-6]
39     int     tm_yday;    /// days since January 1 [0-365]
40     int     tm_isdst;   /// Daylight Savings Time flag
41     c_long  tm_gmtoff;  /// offset from CUT in seconds
42     char*   tm_zone;    /// timezone abbreviation
43 }
44 
45 enum clock_t CLOCKS_PER_SEC = 1_000_000;
46 
47 enum CLOCK_REALTIME                  = 0;
48 enum CLOCK_MONOTIME                  = 1;
49 enum CLOCK_PROCESS_CPUTIME_ID        = 2;
50 enum CLOCK_THREAD_CPUTIME_ID         = 3;
51 
52 clock_t clock();
53 ///
54 void tzset();                            // non-standard
55 ///
56 extern __gshared const(char)*[2] tzname; // non-standard
57 
58 struct time_result_t {
59     time_t timestamp;
60     error_t errno;
61 }
62 
63 alias ulong time_t;
64 
65 time_result_t clock_time_get(clock_t, time_t);