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