Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. time.hxx
  5. Abstract:
  6. This module contains the declaration for the TIMEINFO class.
  7. The data members of the TIMEINFO class contain the date and
  8. time information represented as a FILETIME structure and a
  9. SYSTEMTIME structure. These two representations of date and
  10. time are always initialized independently of the way that the
  11. TIMEINFO class is initialized (as a FILETIME or a SYSTEMTIME).
  12. Author:
  13. Jaime Sasson (jaimes) 13-Mar-1991
  14. Environment:
  15. ULIB, User Mode
  16. --*/
  17. #if !defined( _TIMEINFO_ )
  18. #define _TIMEINFO_
  19. #include "wstring.hxx"
  20. DECLARE_CLASS( TIMEINFO );
  21. class TIMEINFO : public OBJECT {
  22. public:
  23. ULIB_EXPORT
  24. DECLARE_CONSTRUCTOR( TIMEINFO );
  25. NONVIRTUAL
  26. BOOLEAN
  27. Initialize(
  28. );
  29. NONVIRTUAL
  30. ULIB_EXPORT
  31. BOOLEAN
  32. Initialize(
  33. IN PFILETIME FileTime
  34. );
  35. NONVIRTUAL
  36. BOOLEAN
  37. Initialize(
  38. IN PSYSTEMTIME SystemTime
  39. );
  40. NONVIRTUAL
  41. ULIB_EXPORT
  42. VOID
  43. Initialize(
  44. IN PCTIMEINFO TimeInfo
  45. );
  46. NONVIRTUAL
  47. BOOLEAN
  48. Initialize(
  49. IN USHORT Year,
  50. IN USHORT Month,
  51. IN USHORT Day,
  52. IN USHORT Hour,
  53. IN USHORT Minute,
  54. IN USHORT Second,
  55. IN USHORT Milliseconds
  56. );
  57. NONVIRTUAL
  58. SHORT
  59. CompareTimeInfo(
  60. IN PFILETIME FileTime
  61. ) CONST;
  62. NONVIRTUAL
  63. SHORT
  64. CompareTimeInfo(
  65. IN PSYSTEMTIME SystemTime
  66. ) CONST;
  67. NONVIRTUAL
  68. PFILETIME
  69. GetFileTime(
  70. ) CONST;
  71. NONVIRTUAL
  72. PSYSTEMTIME
  73. GetSysTime(
  74. ) CONST;
  75. NONVIRTUAL
  76. BOOLEAN
  77. IsLeapYear(
  78. USHORT Year DEFAULT 0
  79. ) CONST;
  80. NONVIRTUAL
  81. USHORT
  82. QueryYear(
  83. ) CONST;
  84. NONVIRTUAL
  85. USHORT
  86. QueryMonth(
  87. ) CONST;
  88. NONVIRTUAL
  89. USHORT
  90. QueryDay(
  91. ) CONST;
  92. NONVIRTUAL
  93. USHORT
  94. QueryDayOfWeek(
  95. ) CONST;
  96. NONVIRTUAL
  97. USHORT
  98. QueryHour(
  99. ) CONST;
  100. NONVIRTUAL
  101. USHORT
  102. QueryMinute(
  103. ) CONST;
  104. NONVIRTUAL
  105. USHORT
  106. QuerySecond(
  107. ) CONST;
  108. NONVIRTUAL
  109. USHORT
  110. QueryMilliseconds(
  111. ) CONST;
  112. NONVIRTUAL
  113. USHORT
  114. QueryDayOffset(
  115. ) CONST;
  116. NONVIRTUAL
  117. USHORT
  118. QueryDaysInMonth(
  119. ) CONST;
  120. NONVIRTUAL
  121. USHORT
  122. QueryDaysInYear(
  123. ) CONST;
  124. NONVIRTUAL
  125. BOOLEAN
  126. SetDate(
  127. USHORT Year,
  128. USHORT Month,
  129. USHORT Day
  130. );
  131. NONVIRTUAL
  132. BOOLEAN
  133. SetDate(
  134. PCWSTRING Date
  135. );
  136. NONVIRTUAL
  137. BOOLEAN
  138. SetDateAndTime (
  139. PCWSTRING DateAndTime
  140. );
  141. NONVIRTUAL
  142. BOOLEAN
  143. SetTime(
  144. USHORT Hour DEFAULT 0,
  145. USHORT Minute DEFAULT 0,
  146. USHORT Second DEFAULT 0,
  147. USHORT Millisecond DEFAULT 0
  148. );
  149. NONVIRTUAL
  150. BOOLEAN
  151. SetTime(
  152. PCWSTRING Time
  153. );
  154. NONVIRTUAL
  155. ULIB_EXPORT
  156. BOOLEAN
  157. QueryTime(
  158. OUT PWSTRING FormattedTimeString
  159. ) CONST;
  160. NONVIRTUAL
  161. ULIB_EXPORT
  162. BOOLEAN
  163. QueryDate(
  164. OUT PWSTRING FormattedDateString
  165. ) CONST;
  166. NONVIRTUAL
  167. ULIB_EXPORT
  168. BOOLEAN
  169. ConvertToUTC(
  170. );
  171. NONVIRTUAL
  172. ULIB_EXPORT
  173. BOOLEAN
  174. ConvertToLocal(
  175. );
  176. NONVIRTUAL
  177. BOOLEAN
  178. operator== (
  179. IN TIMEINFO TimeInfo
  180. ) CONST;
  181. NONVIRTUAL
  182. BOOLEAN
  183. operator!= (
  184. IN TIMEINFO TimeInfo
  185. ) CONST;
  186. NONVIRTUAL
  187. ULIB_EXPORT
  188. BOOLEAN
  189. operator< (
  190. IN TIMEINFO TimeInfo
  191. ) CONST;
  192. NONVIRTUAL
  193. ULIB_EXPORT
  194. BOOLEAN
  195. operator> (
  196. IN TIMEINFO TimeInfo
  197. ) CONST;
  198. NONVIRTUAL
  199. BOOLEAN
  200. operator<= (
  201. IN TIMEINFO TimeInfo
  202. ) CONST;
  203. NONVIRTUAL
  204. BOOLEAN
  205. operator>= (
  206. IN TIMEINFO TimeInfo
  207. ) CONST;
  208. private:
  209. VOID
  210. Construct (
  211. );
  212. FILETIME _FileTime;
  213. SYSTEMTIME _SystemTime;
  214. };
  215. INLINE
  216. BOOLEAN
  217. TIMEINFO::IsLeapYear(
  218. USHORT Year
  219. ) CONST
  220. /*++
  221. Routine Description:
  222. This member function finds out if the year received as parameter
  223. is a leap year.
  224. Arguments:
  225. Year - Year to be verified. If the year specified is zero, then
  226. the year stored in this class is verified.
  227. Return Value:
  228. BOOLEAN - Indicates if it is a leap year (TRUE) or not (FALSE).
  229. --*/
  230. {
  231. Year = ( Year == 0 )? (USHORT)_SystemTime.wYear : Year;
  232. if( ( ( Year % 400 ) == 0 ) ||
  233. ( ( Year % 100 ) != 0 ) && ( ( Year % 4 ) == 0 ) ) {
  234. return( TRUE );
  235. }
  236. else {
  237. return( FALSE );
  238. }
  239. }
  240. INLINE
  241. USHORT
  242. TIMEINFO::QueryYear(
  243. ) CONST
  244. /*++
  245. Routine Description:
  246. Returns the year stored in the data member of this class.
  247. Arguments:
  248. None.
  249. Return Value:
  250. USHORT - Number representing the year.
  251. --*/
  252. {
  253. return( _SystemTime.wYear );
  254. }
  255. INLINE
  256. USHORT
  257. TIMEINFO::QueryMonth(
  258. ) CONST
  259. /*++
  260. Routine Description:
  261. Returns the month stored in the data member of this class.
  262. Arguments:
  263. None.
  264. Return Value:
  265. USHORT - Number representing the month.
  266. --*/
  267. {
  268. return( _SystemTime.wMonth );
  269. }
  270. INLINE
  271. USHORT
  272. TIMEINFO::QueryDay(
  273. ) CONST
  274. /*++
  275. Routine Description:
  276. Returns the day stored in the data member of this class.
  277. Arguments:
  278. None.
  279. Return Value:
  280. USHORT - Number representing the day.
  281. --*/
  282. {
  283. return( _SystemTime.wDay );
  284. }
  285. INLINE
  286. USHORT
  287. TIMEINFO::QueryDayOfWeek(
  288. ) CONST
  289. /*++
  290. Routine Description:
  291. Returns the day of the week stored in the data member of this class.
  292. Arguments:
  293. None.
  294. Return Value:
  295. USHORT - Number representing the day of the week.
  296. --*/
  297. {
  298. return( _SystemTime.wDayOfWeek );
  299. }
  300. INLINE
  301. USHORT
  302. TIMEINFO::QueryHour(
  303. ) CONST
  304. /*++
  305. Routine Description:
  306. Returns the hour stored in the data member of this class.
  307. Arguments:
  308. None.
  309. Return Value:
  310. USHORT - Number representing the hour.
  311. --*/
  312. {
  313. return( _SystemTime.wHour );
  314. }
  315. INLINE
  316. USHORT
  317. TIMEINFO::QueryMinute(
  318. ) CONST
  319. /*++
  320. Routine Description:
  321. Returns the minutes stored in the data member of this class.
  322. Arguments:
  323. None.
  324. Return Value:
  325. USHORT - Number representing the minutes.
  326. --*/
  327. {
  328. return( _SystemTime.wMinute );
  329. }
  330. INLINE
  331. USHORT
  332. TIMEINFO::QuerySecond(
  333. ) CONST
  334. /*++
  335. Routine Description:
  336. Returns the seconds stored in the data member of this class.
  337. Arguments:
  338. None.
  339. Return Value:
  340. USHORT - Number representing the secondss.
  341. --*/
  342. {
  343. return( _SystemTime.wSecond );
  344. }
  345. INLINE
  346. USHORT
  347. TIMEINFO::QueryMilliseconds(
  348. ) CONST
  349. /*++
  350. Routine Description:
  351. Returns the number of milliseconds stored in the data member of
  352. this class.
  353. Arguments:
  354. None.
  355. Return Value:
  356. USHORT - Number representing the millisecondss.
  357. --*/
  358. {
  359. return( _SystemTime.wMilliseconds );
  360. }
  361. INLINE
  362. PFILETIME
  363. TIMEINFO::GetFileTime(
  364. ) CONST
  365. /*++
  366. Routine Description:
  367. Returns a pointer to the data member that contains the file time.
  368. Arguments:
  369. None.
  370. Return Value:
  371. PFILETIME - Pointer to FileTime.
  372. --*/
  373. {
  374. return( ( PFILETIME )&_FileTime );
  375. }
  376. INLINE
  377. PSYSTEMTIME
  378. TIMEINFO::GetSysTime(
  379. ) CONST
  380. /*++
  381. Routine Description:
  382. Returns a pointer to the data member that contains the system time.
  383. Arguments:
  384. None.
  385. Return Value:
  386. PSYSTEMTIME - Pointer to SystemTime.
  387. --*/
  388. {
  389. return( ( PSYSTEMTIME )&_SystemTime );
  390. }
  391. #endif // _TIMEINFO_