PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/src/core/stdc/time.d

http://github.com/AlexeyProkhin/druntime
D | 120 lines | 97 code | 9 blank | 14 comment | 7 complexity | 503756ec28d1f0278a291db056fa54bb MD5 | raw file
  1/**
  2 * D header file for C99.
  3 *
  4 * Copyright: Copyright Sean Kelly 2005 - 2009.
  5 * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
  6 * Authors:   Sean Kelly,
  7              Alex Rønne Petersen
  8 * Standards: ISO/IEC 9899:1999 (E)
  9 */
 10
 11/*          Copyright Sean Kelly 2005 - 2009.
 12 * Distributed under the Boost Software License, Version 1.0.
 13 *    (See accompanying file LICENSE or copy at
 14 *          http://www.boost.org/LICENSE_1_0.txt)
 15 */
 16module core.stdc.time;
 17
 18private import core.stdc.config;
 19private import core.stdc.stddef; // for size_t
 20
 21extern (C):
 22@trusted: // There are only a few functions here that use unsafe C strings.
 23nothrow:
 24
 25version( Windows )
 26{
 27    struct tm
 28    {
 29        int     tm_sec;     // seconds after the minute - [0, 60]
 30        int     tm_min;     // minutes after the hour - [0, 59]
 31        int     tm_hour;    // hours since midnight - [0, 23]
 32        int     tm_mday;    // day of the month - [1, 31]
 33        int     tm_mon;     // months since January - [0, 11]
 34        int     tm_year;    // years since 1900
 35        int     tm_wday;    // days since Sunday - [0, 6]
 36        int     tm_yday;    // days since January 1 - [0, 365]
 37        int     tm_isdst;   // Daylight Saving Time flag
 38    }
 39}
 40else
 41{
 42    struct tm
 43    {
 44        int     tm_sec;     // seconds after the minute [0-60]
 45        int     tm_min;     // minutes after the hour [0-59]
 46        int     tm_hour;    // hours since midnight [0-23]
 47        int     tm_mday;    // day of the month [1-31]
 48        int     tm_mon;     // months since January [0-11]
 49        int     tm_year;    // years since 1900
 50        int     tm_wday;    // days since Sunday [0-6]
 51        int     tm_yday;    // days since January 1 [0-365]
 52        int     tm_isdst;   // Daylight Savings Time flag
 53        c_long  tm_gmtoff;  // offset from CUT in seconds
 54        char*   tm_zone;    // timezone abbreviation
 55    }
 56}
 57
 58alias c_long time_t;
 59alias c_long clock_t;
 60
 61version( Windows )
 62{
 63    enum clock_t CLOCKS_PER_SEC = 1000;
 64}
 65else version( OSX )
 66{
 67    enum clock_t CLOCKS_PER_SEC = 100;
 68}
 69else version( FreeBSD )
 70{
 71    enum clock_t CLOCKS_PER_SEC = 128;
 72}
 73else version (linux)
 74{
 75    enum clock_t CLOCKS_PER_SEC = 1000000;
 76}
 77
 78clock_t clock();
 79double  difftime(time_t time1, time_t time0);
 80time_t  mktime(tm* timeptr);
 81time_t  time(time_t* timer);
 82char*   asctime(in tm* timeptr);
 83char*   ctime(in time_t* timer);
 84tm*     gmtime(in time_t* timer);
 85tm*     localtime(in time_t* timer);
 86@system size_t  strftime(char* s, size_t maxsize, in char* format, in tm* timeptr);
 87
 88version( Windows )
 89{
 90    void  tzset();                           // non-standard
 91    void  _tzset();                          // non-standard
 92    @system char* _strdate(char* s);                 // non-standard
 93    @system char* _strtime(char* s);                 // non-standard
 94
 95    extern __gshared const(char)*[2] tzname; // non-standard
 96}
 97else version( OSX )
 98{
 99    void tzset();                            // non-standard
100    extern __gshared const(char)*[2] tzname; // non-standard
101}
102else version( linux )
103{
104    void tzset();                            // non-standard
105    extern __gshared const(char)*[2] tzname; // non-standard
106}
107else version( FreeBSD )
108{
109    void tzset();                            // non-standard
110    extern __gshared const(char)*[2] tzname; // non-standard
111}
112else version (Solaris)
113{
114    void tzset();
115    extern __gshared const(char)*[2] tzname;
116}
117else
118{
119    static assert(false, "Unsupported platform");
120}