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