time.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef __TIME_H
  2. #define __TIME_H
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. */
  35. /*
  36. * $Log: time.h,v $
  37. * Revision 1.6 2005/01/19 17:03:35 freckle
  38. * forget to check in other cygwin fixes
  39. *
  40. * Revision 1.5 2004/04/07 12:13:57 haraldkipp
  41. * Matthias Ringwald's *nix emulation added
  42. *
  43. * Revision 1.4 2004/03/16 16:48:27 haraldkipp
  44. * Added Jan Dubiec's H8/300 port.
  45. *
  46. * Revision 1.3 2003/12/19 22:24:25 drsung
  47. * Dox written.
  48. *
  49. * Revision 1.2 2003/11/26 11:15:34 haraldkipp
  50. * Portability issues
  51. *
  52. * Revision 1.1 2003/11/24 18:11:03 drsung
  53. * first release
  54. *
  55. *
  56. */
  57. /*!
  58. * \file time.h
  59. * \brief Standard C time handling functions.
  60. */
  61. #include <compiler.h>
  62. #include <sys/types.h>
  63. /*!
  64. * \addtogroup xgCrtTime
  65. * @{
  66. */
  67. __BEGIN_DECLS
  68. /*!
  69. * \brief Type definition for struct _tm
  70. */
  71. typedef struct _tm tm;
  72. /*!
  73. * \brief structure to store a date/time value.
  74. *
  75. * The structure tm stores a complete date and time combination. The granularity
  76. * is one second.
  77. *
  78. * \note The range of \b tm_mon is from 0 (January) to 11 (December).\n
  79. * \b tm_year holds the year since 1900, for example value 103 means year 2003.
  80. */
  81. struct _tm {
  82. int tm_sec; /*!< \brief seconds after the minute - [0,59] */
  83. int tm_min; /*!< \brief minutes after the hour - [0,59] */
  84. int tm_hour; /*!< \brief hours since midnight - [0,23] */
  85. int tm_mday; /*!< \brief day of the month - [1,31] */
  86. int tm_mon; /*!< \brief months since January - [0,11] */
  87. int tm_year; /*!< \brief years since 1900 */
  88. int tm_wday; /*!< \brief days since Sunday - [0,6] */
  89. int tm_yday; /*!< \brief days since January 1 - [0,365] */
  90. int tm_isdst; /*!< \brief daylight savings time flag */
  91. };
  92. /*!
  93. * \typedef long time_t
  94. * \brief Serial date/time. Holds number of seconds after January 1st, 1970.
  95. */
  96. #if !defined(__APPLE__) && !defined(__CYGWIN__)
  97. typedef long time_t;
  98. #endif
  99. #ifdef __linux__
  100. /* make compiler on linux gcc-2.95 happy */
  101. struct timespec;
  102. #endif
  103. time_t time(time_t * timer);
  104. int gmtime_r(CONST time_t * timer, tm * theTime);
  105. tm *gmtime(CONST time_t * timer);
  106. int localtime_r(CONST time_t * timer, tm * theTime);
  107. tm *localtime(CONST time_t * timer);
  108. int stime(time_t * timer);
  109. time_t mktime(tm * timeptr);
  110. time_t _mkgmtime(tm * timeptr);
  111. /*!
  112. * \brief Used to control daylight conversions.
  113. *
  114. * Assign a nonzero value to enable daylight conversions. If enabled
  115. * the hour part of time values is adjusted if we are in daylight saving time.
  116. * Zero value to disable conversion.
  117. * Default is enabled.
  118. */
  119. extern u_char _daylight;
  120. /*!
  121. * \brief Defines your local timezone.
  122. *
  123. * Difference in seconds between universal coordinated time and local time.
  124. * This value is subtracted from the universal coordinated time to
  125. * calculate your local time. Default value is 5 * 60 * 60 = 18000,
  126. * which defines the time zone EST (GMT-5).
  127. *
  128. * \note Before using the time functions, set \b _timezone to your
  129. * local value.
  130. *
  131. */
  132. extern long _timezone;
  133. /*!
  134. * \brief Difference between standard and daylight savings time in seconds.
  135. *
  136. * This value is used to calculate the daylight savings time by subtracting this
  137. * value from the standard time. Unit is seconds.
  138. * Usually daylight savings time is one hour in advance to standard time, thus the default
  139. * value is -1 * 60 * 60 = -3600.
  140. */
  141. extern long _dstbias;
  142. __END_DECLS
  143. /*@}*/
  144. #endif