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.posix.stdc.time; 17 18 version (Posix): 19 20 import core.stdc.config; 21 22 version (OSX) 23 version = Darwin; 24 else version (iOS) 25 version = Darwin; 26 else version (TVOS) 27 version = Darwin; 28 else version (WatchOS) 29 version = Darwin; 30 31 extern (C): 32 @trusted: // There are only a few functions here that use unsafe C strings. 33 nothrow: 34 @nogc: 35 36 /// 37 struct tm 38 { 39 int tm_sec; /// seconds after the minute [0-60] 40 int tm_min; /// minutes after the hour [0-59] 41 int tm_hour; /// hours since midnight [0-23] 42 int tm_mday; /// day of the month [1-31] 43 int tm_mon; /// months since January [0-11] 44 int tm_year; /// years since 1900 45 int tm_wday; /// days since Sunday [0-6] 46 int tm_yday; /// days since January 1 [0-365] 47 int tm_isdst; /// Daylight Savings Time flag 48 c_long tm_gmtoff; /// offset from CUT in seconds 49 char* tm_zone; /// timezone abbreviation 50 } 51 52 public import core.sys.posix.sys.types : time_t, clock_t; 53 54 /// version(OSX)55version (OSX) 56 { 57 enum clock_t CLOCKS_PER_SEC = 1_000_000; // was 100 until OSX 10.4/10.5 58 version (X86) 59 extern (C) pragma(mangle, "clock$UNIX2003") clock_t clock(); 60 else 61 clock_t clock(); 62 } version(Darwin)63else version (Darwin) // other Darwins (iOS, TVOS, WatchOS) 64 { 65 enum clock_t CLOCKS_PER_SEC = 1_000_000; 66 clock_t clock(); 67 } version(FreeBSD)68else version (FreeBSD) 69 { 70 enum clock_t CLOCKS_PER_SEC = 128; 71 clock_t clock(); 72 } version(NetBSD)73else version (NetBSD) 74 { 75 enum clock_t CLOCKS_PER_SEC = 100; 76 clock_t clock(); 77 } version(OpenBSD)78else version (OpenBSD) 79 { 80 enum clock_t CLOCKS_PER_SEC = 100; 81 clock_t clock(); 82 } version(DragonFlyBSD)83else version (DragonFlyBSD) 84 { 85 enum clock_t CLOCKS_PER_SEC = 128; 86 clock_t clock(); 87 } version(Solaris)88else version (Solaris) 89 { 90 enum clock_t CLOCKS_PER_SEC = 1_000_000; 91 clock_t clock(); 92 } version(CRuntime_Glibc)93else version (CRuntime_Glibc) 94 { 95 enum clock_t CLOCKS_PER_SEC = 1_000_000; 96 clock_t clock(); 97 } version(CRuntime_Musl)98else version (CRuntime_Musl) 99 { 100 enum clock_t CLOCKS_PER_SEC = 1_000_000; 101 clock_t clock(); 102 } version(CRuntime_Bionic)103else version (CRuntime_Bionic) 104 { 105 enum clock_t CLOCKS_PER_SEC = 1_000_000; 106 clock_t clock(); 107 } version(CRuntime_UClibc)108else version (CRuntime_UClibc) 109 { 110 enum clock_t CLOCKS_PER_SEC = 1_000_000; 111 clock_t clock(); 112 } 113 else 114 { 115 static assert(0, "unsupported system"); 116 } 117 version(Darwin)118version (Darwin) 119 { 120 /// 121 void tzset(); // non-standard 122 /// 123 extern __gshared const(char)*[2] tzname; // non-standard 124 } version(CRuntime_Glibc)125else version (CRuntime_Glibc) 126 { 127 /// 128 void tzset(); // non-standard 129 /// 130 extern __gshared const(char)*[2] tzname; // non-standard 131 } version(FreeBSD)132else version (FreeBSD) 133 { 134 /// 135 void tzset(); // non-standard 136 /// 137 extern __gshared const(char)*[2] tzname; // non-standard 138 } version(NetBSD)139else version (NetBSD) 140 { 141 /// 142 void tzset(); // non-standard 143 /// 144 extern __gshared const(char)*[2] tzname; // non-standard 145 } version(OpenBSD)146else version (OpenBSD) 147 { 148 /// 149 void tzset(); // non-standard 150 /// 151 extern __gshared const(char)*[2] tzname; // non-standard 152 } version(DragonFlyBSD)153else version (DragonFlyBSD) 154 { 155 /// 156 void tzset(); // non-standard 157 /// 158 extern __gshared const(char)*[2] tzname; // non-standard 159 } version(Solaris)160else version (Solaris) 161 { 162 /// 163 void tzset(); 164 /// 165 extern __gshared const(char)*[2] tzname; 166 } version(CRuntime_Bionic)167else version (CRuntime_Bionic) 168 { 169 /// 170 void tzset(); 171 /// 172 extern __gshared const(char)*[2] tzname; 173 } version(CRuntime_Musl)174else version (CRuntime_Musl) 175 { 176 /// 177 void tzset(); // non-standard 178 /// 179 extern __gshared const(char)*[2] tzname; // non-standard 180 } version(CRuntime_UClibc)181else version (CRuntime_UClibc) 182 { 183 /// 184 void tzset(); 185 /// 186 extern __gshared const(char)*[2] tzname; 187 } 188 else 189 { 190 static assert(false, "Unsupported platform"); 191 } 192