time.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. time.h
  5. Abstract:
  6. This header contains internal definitions for time functions within the
  7. runtime library base.
  8. Author:
  9. Evan Green 31-Aug-2015
  10. --*/
  11. //
  12. // ------------------------------------------------------------------- Includes
  13. //
  14. //
  15. // ---------------------------------------------------------------- Definitions
  16. //
  17. //
  18. // ------------------------------------------------------ Data Type Definitions
  19. //
  20. //
  21. // -------------------------------------------------------------------- Globals
  22. //
  23. //
  24. // Store the global pointer to the time zone data.
  25. //
  26. extern PVOID RtlTimeZoneData;
  27. extern ULONG RtlTimeZoneDataSize;
  28. extern ULONG RtlTimeZoneIndex;
  29. extern PTIME_ZONE_LOCK_FUNCTION RtlAcquireTimeZoneLock;
  30. extern PTIME_ZONE_LOCK_FUNCTION RtlReleaseTimeZoneLock;
  31. //
  32. // Store arrays of the names of the months and weeks.
  33. //
  34. extern PSTR RtlMonthStrings[MONTHS_PER_YEAR];
  35. extern PSTR RtlAbbreviatedMonthStrings[MONTHS_PER_YEAR];
  36. extern PSTR RtlWeekdayStrings[DAYS_PER_WEEK];
  37. extern PSTR RtlAbbreviatedWeekdayStrings[DAYS_PER_WEEK];
  38. extern PSTR RtlAmPmStrings[2][2];
  39. extern CHAR RtlDaysPerMonth[2][MONTHS_PER_YEAR];
  40. extern SHORT RtlMonthDays[2][MONTHS_PER_YEAR];
  41. //
  42. // -------------------------------------------------------- Function Prototypes
  43. //
  44. LONG
  45. RtlpComputeYearForDays (
  46. PLONG Days
  47. );
  48. /*++
  49. Routine Description:
  50. This routine calculates the year given a number of days from the epoch.
  51. Arguments:
  52. Days - Supplies a pointer to the number of days since the epoch. On
  53. completion, this will contain the number of remaining days after the
  54. years have been subtracted.
  55. Return Value:
  56. Returns the year that the day resides in.
  57. --*/
  58. LONG
  59. RtlpComputeDaysForYear (
  60. LONG Year
  61. );
  62. /*++
  63. Routine Description:
  64. This routine calculates the number of days for the given year, relative to
  65. the epoch.
  66. Arguments:
  67. Year - Supplies the target year.
  68. Return Value:
  69. Returns the number of days since the epoch that January 1st of the given
  70. year occurred.
  71. --*/
  72. KSTATUS
  73. RtlpCalculateWeekdayForMonth (
  74. LONG Year,
  75. LONG Month,
  76. PLONG Weekday
  77. );
  78. /*++
  79. Routine Description:
  80. This routine calculates the weekday for the first of the month on the
  81. given month and year.
  82. Arguments:
  83. Year - Supplies the year to calculate the weekday for.
  84. Month - Supplies the month to calculate the weekday for.
  85. Weekday - Supplies a pointer where the weekday will be returned on success.
  86. Return Value:
  87. STATUS_SUCCESS on success.
  88. STATUS_OUT_OF_BOUNDS on failure.
  89. --*/
  90. VOID
  91. RtlpNormalizeCalendarTime (
  92. PCALENDAR_TIME CalendarTime
  93. );
  94. /*++
  95. Routine Description:
  96. This routine normalizes the fields in a calendar time structure, putting
  97. them in their proper ranges.
  98. Arguments:
  99. CalendarTime - Supplies a pointer to the calendar time structure to
  100. normalize.
  101. Return Value:
  102. None.
  103. --*/
  104. KSTATUS
  105. RtlpCalculateWeekNumber (
  106. LONG Year,
  107. LONG YearDay,
  108. LONG StartingWeekday,
  109. PLONG WeekNumber
  110. );
  111. /*++
  112. Routine Description:
  113. This routine calculates the week number given a year and year day.
  114. Arguments:
  115. Year - Supplies the year the week resides in.
  116. YearDay - Supplies the day of the of the year. Valid values are between 0
  117. and 365.
  118. StartingWeekday - Supplies the weekday of the start of the week. Usually
  119. this is Sunday (0) or Monday (1).
  120. WeekNumber - Supplies a pointer where the week number will be returned.
  121. Return Value:
  122. STATUS_SUCCESS on success.
  123. STATUS_OUT_OF_BOUNDS on failure.
  124. --*/
  125. KSTATUS
  126. RtlpCalculateIsoWeekNumber (
  127. LONG Year,
  128. LONG YearDay,
  129. LONG Weekday,
  130. PLONG WeekNumber,
  131. PLONG IsoYear
  132. );
  133. /*++
  134. Routine Description:
  135. This routine calculates the ISO 8601 week-based year week number and year.
  136. Arguments:
  137. Year - Supplies the Gregorian calendar year.
  138. YearDay - Supplies the day of the of the year. Valid values are between 0
  139. and 365.
  140. Weekday - Supplies the day of the week. Valid values are between 0 and 6,
  141. with 0 as Sunday.
  142. WeekNumber - Supplies an optional pointer where the ISO week number will be
  143. returned.
  144. IsoYear - Supplies an optional pointer where the ISO year will be returned.
  145. Return Value:
  146. STATUS_SUCCESS on success.
  147. STATUS_OUT_OF_BOUNDS on failure.
  148. --*/