time.h 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. time.h
  9. Abstract:
  10. This header contains time related definitions.
  11. Author:
  12. Evan Green 22-Jul-2013
  13. --*/
  14. #ifndef _TIME_H
  15. #define _TIME_H
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <libcbase.h>
  20. #include <signal.h>
  21. #include <stddef.h>
  22. //
  23. // ---------------------------------------------------------------- Definitions
  24. //
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. //
  29. // Define the types of clocks that can be accessed.
  30. //
  31. //
  32. // Wall clock time
  33. //
  34. #define CLOCK_REALTIME 0
  35. //
  36. // High resolution hardware timer
  37. //
  38. #define CLOCK_MONOTONIC 1
  39. //
  40. // CPU time for the process
  41. //
  42. #define CLOCK_PROCESS_CPUTIME_ID 2
  43. //
  44. // CPU time for the thread
  45. //
  46. #define CLOCK_THREAD_CPUTIME_ID 3
  47. //
  48. // Monotonic clock, unscaled
  49. //
  50. #define CLOCK_MONOTONIC_RAW 4
  51. //
  52. // Recent realtime clock value, updated regularly.
  53. //
  54. #define CLOCK_REALTIME_COARSE 5
  55. //
  56. // Recent monotonic clock value, updated regularly.
  57. //
  58. #define CLOCK_MONOTONIC_COARSE 6
  59. //
  60. // Monotonic clock value plus time spent in suspension.
  61. //
  62. #define CLOCK_BOOTTIME 7
  63. //
  64. // Define the flags that can be passed to the set timer function.
  65. //
  66. //
  67. // Set this flag to indicate that the value to be set is an absolute time.
  68. //
  69. #define TIMER_ABSTIME 0x00000001
  70. //
  71. // Define the value to convert the units returned in the clock function to
  72. // seconds.
  73. //
  74. #define CLOCKS_PER_SEC 1000000
  75. //
  76. // ------------------------------------------------------ Data Type Definitions
  77. //
  78. /*++
  79. Structure Description:
  80. This structure stores information about an interval timer.
  81. Members:
  82. it_interval - Stores the period of the timer for periodic timers, or 0.0 if
  83. the timer is a one-shot timer.
  84. it_value - Stores the due time of the timer.
  85. --*/
  86. struct itimerspec {
  87. struct timespec it_interval;
  88. struct timespec it_value;
  89. };
  90. /*++
  91. Structure Description:
  92. This structure describes the C library concept of calendar time.
  93. Members:
  94. tm_sec - Stores the second. Valid values are between 0 and 60 (for leap
  95. seconds).
  96. tm_min - Stores the minute. Valid values are between 0 and 59.
  97. tm_hour - Stores the hour. Valid values are between 0 and 23.
  98. tm_mday - Stores the day of the month. Valid values are between 1 and 31.
  99. tm_mon - Stores the month. Valid values are between 0 and 11.
  100. tm_year - Stores the number of years since 1900. Valid values are between
  101. -1899 and 8099 (for actual calendar years between 1 and 9999).
  102. tm_wday - Stores the day of the week. Valid values are between 0 and 6,
  103. with 0 being Sunday and 6 being Saturday.
  104. tm_yday - Stores the day of the year. Valid values are between 0 and 365.
  105. tm_isdst - Stores a value indicating if the given time is represented in
  106. daylight saving time. Usually 0 indicates standard time, 1 indicates
  107. daylight saving time, and -1 indicates "unknown".
  108. tm_nanosecond - Stores the nanosecond. Valid values are between 0 and
  109. 999,999,999.
  110. tm_gmtoff - Stores the offset from Greenwich Mean Time in seconds that
  111. this time is interpreted in.
  112. tm_zone - Stores a pointer to a constant string containing the time zone
  113. name. The user should not modify or free this buffer.
  114. --*/
  115. struct tm {
  116. int tm_sec;
  117. int tm_min;
  118. int tm_hour;
  119. int tm_mday;
  120. int tm_mon;
  121. int tm_year;
  122. int tm_wday;
  123. int tm_yday;
  124. int tm_isdst;
  125. int tm_nanosecond;
  126. int tm_gmtoff;
  127. const char *tm_zone;
  128. };
  129. //
  130. // -------------------------------------------------------------------- Globals
  131. //
  132. //
  133. // This variable is set to zero if Daylight Saving time should never be applied
  134. // for the timezone in use, or non-zero otherwise.
  135. //
  136. LIBC_API extern int daylight;
  137. //
  138. // This variable is set to the difference in seconds between Universal
  139. // Coordinated Time (UTC) and local standard time.
  140. //
  141. LIBC_API extern long timezone;
  142. //
  143. // This variable is set to contain two pointers to strings. The first one
  144. // points to the name of the timezone in standard time, and the second one
  145. // pointers to the name of the timezone in Daylight Saving time.
  146. //
  147. LIBC_API extern char *tzname[2];
  148. //
  149. // -------------------------------------------------------- Function Prototypes
  150. //
  151. LIBC_API
  152. clock_t
  153. clock (
  154. void
  155. );
  156. /*++
  157. Routine Description:
  158. This routine returns the best approximation of the processor time used
  159. by the process since the process invocation.
  160. Arguments:
  161. None.
  162. Return Value:
  163. Returns the clock time used by the current process, which can be divided
  164. by CLOCKS_PER_SEC to get the number of seconds of processor time used by
  165. the process.
  166. -1 if the processor time is not available or cannot be represented.
  167. --*/
  168. LIBC_API
  169. int
  170. clock_getcpuclockid (
  171. pid_t ProcessId,
  172. clockid_t *ClockId
  173. );
  174. /*++
  175. Routine Description:
  176. This routine gets the clock ID for the CPU time clock of the given
  177. process.
  178. Arguments:
  179. ProcessId - Supplies the ID of the process whose CPU time clock ID is being
  180. queried.
  181. ClockId - Supplies a pointer that receives the CPU time clock ID for the
  182. given process.
  183. Return Value:
  184. 0 on success. The returned clock ID will be in the clock ID parameter.
  185. -1 on failure, and errno will be set to contain more information.
  186. --*/
  187. LIBC_API
  188. int
  189. clock_getres (
  190. clockid_t ClockId,
  191. struct timespec *Resolution
  192. );
  193. /*++
  194. Routine Description:
  195. This routine gets the resolution for the given clock. Time values for calls
  196. to get or set this clock will be limited by the precision of the resolution.
  197. Arguments:
  198. ClockId - Supplies the ID of the clock whose resolution is to be queried.
  199. Resolution - Supplies a pointer that receives the resolution of the given
  200. clock.
  201. Return Value:
  202. 0 on success. The returned resolution will be in the resolution parameter.
  203. -1 on failure, and errno will be set to contain more information.
  204. --*/
  205. LIBC_API
  206. int
  207. clock_gettime (
  208. clockid_t ClockId,
  209. struct timespec *Time
  210. );
  211. /*++
  212. Routine Description:
  213. This routine gets the current time for the given clock.
  214. Arguments:
  215. ClockId - Supplies the ID of the clock whose time is being queried.
  216. Time - Supplies a pointer that receives the current value of the queried
  217. clock.
  218. Return Value:
  219. 0 on success. The returned time will be in the time parameter.
  220. -1 on failure, and errno will be set to contain more information.
  221. --*/
  222. LIBC_API
  223. int
  224. clock_settime (
  225. clockid_t ClockId,
  226. const struct timespec *NewTime
  227. );
  228. /*++
  229. Routine Description:
  230. This routine sets the time for the given clock.
  231. Arguments:
  232. ClockId - Supplies the ID of the clock whose time is to be set.
  233. NewTime - Supplies a pointer to the new time to set for the given clock.
  234. Return Value:
  235. 0 on success.
  236. -1 on failure, and errno will be set to contain more information.
  237. --*/
  238. LIBC_API
  239. int
  240. clock_nanosleep (
  241. clockid_t ClockId,
  242. int Flags,
  243. const struct timespec *RequestedTime,
  244. struct timespec *RemainingTime
  245. );
  246. /*++
  247. Routine Description:
  248. This routine suspends execution of the calling thread until either the
  249. given clock interval has expired or a signal is delivered. If absolute time
  250. is specified, then the thread will be suspended until the absolute time is
  251. reached or a signal is delivered.
  252. Arguments:
  253. ClockId - Supplies the ID of the clock to use to measure the requested time.
  254. Flags - Supplies a bitmask of flags. See TIMER_*.
  255. RequestedTime - Supplies a pointer to the requested time interval to wait
  256. or the absolute time until which to wait.
  257. RemainingTime - Supplies an optional pointer that receives the remaining
  258. time if the thread is interrupted by a signal.
  259. Return Value:
  260. 0 on success or standard error value on failure or interruption.
  261. --*/
  262. LIBC_API
  263. char *
  264. asctime (
  265. const struct tm *Time
  266. );
  267. /*++
  268. Routine Description:
  269. This routine converts the given time structure into a string. This routine
  270. is neither reentrant nor thread safe, and the results returned may be
  271. overwritten by subsequent calls to ctime, gmtime, and localtime. It is
  272. recommended that new applications use asctime_r. The format of the result
  273. takes the following form (as an example): "Tue Jan 28 11:38:09 1986".
  274. Arguments:
  275. Time - Supplies a pointer to the time structure to convert.
  276. Return Value:
  277. Returns a pointer to the buffer on success.
  278. NULL on failure.
  279. --*/
  280. LIBC_API
  281. char *
  282. asctime_r (
  283. const struct tm *Time,
  284. char *Buffer
  285. );
  286. /*++
  287. Routine Description:
  288. This routine converts the given time structure into a string. This routine
  289. is reentrant and thread safe, as it uses only the passed in buffers. The
  290. format of the result takes the following form (as an example):
  291. "Tue Jan 28 11:38:09 1986".
  292. Arguments:
  293. Time - Supplies a pointer to the time structure to convert.
  294. Buffer - Supplies a pointer to a buffer that must be at least 26 bytes in
  295. size.
  296. Return Value:
  297. Returns a pointer to the buffer on success.
  298. NULL on failure.
  299. --*/
  300. LIBC_API
  301. char *
  302. ctime (
  303. const time_t *TimeValue
  304. );
  305. /*++
  306. Routine Description:
  307. This routine converts the given time structure into a string. This routine
  308. is neither reentrant nor thread safe, and the results returned may be
  309. overwritten by subsequent calls to ctime, gmtime, and localtime. It is
  310. recommended that new applications use ctime_r. This routine is equivalent
  311. to calling asctime(localtime(Time)).
  312. Arguments:
  313. TimeValue - Supplies the time value to convert.
  314. Return Value:
  315. Returns a pointer to the buffer on success.
  316. NULL on failure.
  317. --*/
  318. LIBC_API
  319. char *
  320. ctime_r (
  321. const time_t *TimeValue,
  322. char *Buffer
  323. );
  324. /*++
  325. Routine Description:
  326. This routine converts the given time structure into a string. This routine
  327. is reentrant and thread safe, as it uses only the passed in buffers. This
  328. routine is equivalent to calling asctime(localtime(Time)).
  329. Arguments:
  330. TimeValue - Supplies the time value to convert.
  331. Buffer - Supplies a pointer to a buffer that must be at least 26 bytes in
  332. size.
  333. Return Value:
  334. Returns a pointer to the buffer on success.
  335. NULL on failure.
  336. --*/
  337. LIBC_API
  338. double
  339. difftime (
  340. time_t LeftTimeValue,
  341. time_t RightTimeValue
  342. );
  343. /*++
  344. Routine Description:
  345. This routine computes the difference between two time values:
  346. LeftTimeValue - RightTimeValue.
  347. Arguments:
  348. LeftTimeValue - Supplies the first time value, the value to subtract from.
  349. RightTimeValue - Supplies the second time value, the value to subtract.
  350. Return Value:
  351. Returns the number of seconds between the two times as a double.
  352. --*/
  353. LIBC_API
  354. struct tm *
  355. gmtime (
  356. const time_t *TimeValue
  357. );
  358. /*++
  359. Routine Description:
  360. This routine converts the given time value into a broken down calendar time
  361. in the GMT time zone. This routine is neither reentrant nor thread safe.
  362. Arguments:
  363. TimeValue - Supplies a pointer to the time value to convert.
  364. Return Value:
  365. Returns a pointer to a broken down time structure on success. This buffer
  366. may be overwritten by subsequent calls to gmtime or localtime.
  367. --*/
  368. LIBC_API
  369. struct tm *
  370. gmtime_r (
  371. const time_t *TimeValue,
  372. struct tm *Result
  373. );
  374. /*++
  375. Routine Description:
  376. This routine converts the given time value into a broken down calendar time
  377. in the GMT time zone. This routine is reentrant and thread safe.
  378. Arguments:
  379. TimeValue - Supplies a pointer to the time value to convert.
  380. Result - Supplies a pointer where the result will be returned.
  381. Return Value:
  382. Returns the result parameter on success.
  383. NULL on failure.
  384. --*/
  385. LIBC_API
  386. struct tm *
  387. localtime (
  388. const time_t *TimeValue
  389. );
  390. /*++
  391. Routine Description:
  392. This routine converts the given time value into a broken down calendar time
  393. in the current local time zone. This routine is neither reentrant nor
  394. thread safe.
  395. Arguments:
  396. TimeValue - Supplies a pointer to the time value to convert.
  397. Return Value:
  398. Returns a pointer to a broken down time structure on success. This buffer
  399. may be overwritten by subsequent calls to gmtime or localtime.
  400. --*/
  401. LIBC_API
  402. struct tm *
  403. localtime_r (
  404. const time_t *TimeValue,
  405. struct tm *Result
  406. );
  407. /*++
  408. Routine Description:
  409. This routine converts the given time value into a broken down calendar time
  410. in the current local time zone. This routine is reentrant and thread safe.
  411. Arguments:
  412. TimeValue - Supplies a pointer to the time value to convert.
  413. Result - Supplies a pointer where the result will be returned.
  414. Return Value:
  415. Returns the result parameter on success.
  416. NULL on failure.
  417. --*/
  418. LIBC_API
  419. time_t
  420. timegm (
  421. struct tm *Time
  422. );
  423. /*++
  424. Routine Description:
  425. This routine converts a broken down time structure, given in GMT time, back
  426. into its corresponding time value, in seconds since the Epoch, midnight on
  427. January 1, 1970 GMT. It will also normalize the given time structure so
  428. that each member is in the correct range.
  429. Arguments:
  430. Time - Supplies a pointer to the broken down time structure.
  431. Return Value:
  432. Returns the time value corresponding to the given broken down time.
  433. -1 on failure, and errno will be set to contain more information. Note that
  434. -1 can also be returned as a valid offset from the Epoch.
  435. --*/
  436. LIBC_API
  437. time_t
  438. mktime (
  439. struct tm *Time
  440. );
  441. /*++
  442. Routine Description:
  443. This routine converts a broken down time structure, given in local time,
  444. back into its corresponding time value, in seconds since the Epoch,
  445. midnight on January 1, 1970 GMT. It will also normalize the given time
  446. structure so that each member is in the correct range.
  447. Arguments:
  448. Time - Supplies a pointer to the broken down time structure.
  449. Return Value:
  450. Returns the time value corresponding to the given broken down time.
  451. -1 on failure, and errno will be set to contain more information. Note that
  452. -1 can also be returned as a valid offset from the Epoch.
  453. --*/
  454. LIBC_API
  455. size_t
  456. strftime (
  457. char *Buffer,
  458. size_t BufferSize,
  459. const char *Format,
  460. const struct tm *Time
  461. );
  462. /*++
  463. Routine Description:
  464. This routine converts the given calendar time into a string governed by
  465. the given format string.
  466. Arguments:
  467. Buffer - Supplies a pointer where the converted string will be returned.
  468. BufferSize - Supplies the size of the string buffer in bytes.
  469. Format - Supplies the format string to govern the conversion. Ordinary
  470. characters in the format string will be copied verbatim to the output
  471. string. Conversions will be substituted for their corresponding value
  472. in the provided calendar time. Conversions start with a '%' character,
  473. followed by an optional E or O character, followed by a conversion
  474. specifier. The conversion specifier can take the following values:
  475. %a - Replaced by the abbreviated weekday.
  476. %A - Replaced by the full weekday.
  477. %b - Replaced by the abbreviated month name.
  478. %B - Replaced by the full month name.
  479. %c - Replaced by the locale's appropriate date and time representation.
  480. %C - Replaced by the year divided by 100 (century) [00,99].
  481. %d - Replaced by the day of the month [01,31].
  482. %D - Equivalent to "%m/%d/%y".
  483. %e - Replaced by the day of the month [ 1,31]. A single digit is
  484. preceded by a space.
  485. %F - Equivalent to "%Y-%m-%d" (the ISO 8601:2001 date format).
  486. %G - The ISO 8601 week-based year [0001,9999]. The week-based year and
  487. the Gregorian year can differ in the first week of January.
  488. %h - Equivalent to %b (abbreviated month).
  489. %H - Replaced by the 24 hour clock hour [00,23].
  490. %I - Replaced by the 12 hour clock hour [01,12].
  491. %J - Replaced by the nanosecond [0,999999999].
  492. %j - Replaced by the day of the year [001,366].
  493. %m - Replaced by the month number [01,12].
  494. %M - Replaced by the minute [00,59].
  495. %N - Replaced by the microsecond [0,999999]
  496. %n - Replaced by a newline.
  497. %p - Replaced by "AM" or "PM".
  498. %P - Replaced by "am" or "pm".
  499. %q - Replaced by the millisecond [0,999].
  500. %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
  501. %R - Replaced by the time in 24 hour notation: "%H:%M".
  502. %S - Replaced by the second [00,60].
  503. %s - Replaced by the number of seconds since 1970 GMT.
  504. %t - Replaced by a tab.
  505. %T - Replaced by the time: "%H:%M:%S".
  506. %u - Replaced by the weekday number, with 1 representing Monday [1,7].
  507. %U - Replaced by the week number of the year [00,53]. The first Sunday
  508. of January is the first day of week 1. Days before this are week 0.
  509. %V - Replaced by the week number of the year with Monday as the first
  510. day in the week [01,53]. If the week containing January 1st has 4
  511. or more days in the new year, it is considered week 1. Otherwise,
  512. it is the last week of the previous year, and the next week is 1.
  513. %w - Replaced by the weekday number [0,6], with 0 representing Sunday.
  514. %W - Replaced by the week number [00,53]. The first Monday of January
  515. is the first day of week 1. Days before this are in week 0.
  516. %x - Replaced by the locale's appropriate date representation.
  517. %X - Replaced by the locale's appropriate time representation.
  518. %y - Replaced by the last two digits of the year [00,99].
  519. %Y - Replaced by the full four digit year [0001,9999].
  520. %z - Replaced by the offset from UTC in the standard ISO 8601:2000
  521. standard format (+hhmm or -hhmm), or by no characters if no
  522. timezone is terminable. If the "is daylight saving" member of the
  523. calendar structure is greater than zero, then the daylight saving
  524. offset is used. If the dayslight saving member of the calendar
  525. structure is negative, no characters are returned.
  526. %Z - Replaced by the timezone name or abbreviation, or by no bytes if
  527. no timezone information exists.
  528. %% - Replaced by a literal '%'.
  529. Time - Supplies a pointer to the calendar time value to use in the
  530. substitution.
  531. Return Value:
  532. Returns the number of characters written to the output buffer, including
  533. the null terminator.
  534. --*/
  535. LIBC_API
  536. char *
  537. strptime (
  538. const char *Buffer,
  539. const char *Format,
  540. struct tm *Time
  541. );
  542. /*++
  543. Routine Description:
  544. This routine scans the given input string into values in the calendar time,
  545. using the specified format.
  546. Arguments:
  547. Buffer - Supplies a pointer to the null terminated string to scan.
  548. Format - Supplies the format string to govern the conversion. Ordinary
  549. characters in the format string will be scanned verbatim from the input.
  550. Whitespace characters in the format will cause all whitespace at the
  551. current position in the input to be scanned. Conversions will be
  552. scanned for their corresponding value in the provided calendar time.
  553. Conversions start with a '%' character, followed by an optional E or O
  554. character, followed by a conversion specifier. The conversion specifier
  555. can take the following values:
  556. %a - The day of the weekday name, either the full or abbreviated name.
  557. %A - Equivalent to %a.
  558. %b - The month name, either the full or abbreviated name.
  559. %B - Equivalent to %b.
  560. %c - Replaced by the locale's appropriate date and time representation.
  561. %C - The year divided by 100 (century) [00,99].
  562. %d - The day of the month [01,31].
  563. %D - Equivalent to "%m/%d/%y".
  564. %e - Equivalent to %d.
  565. %h - Equivalent to %b (month name).
  566. %H - The 24 hour clock hour [00,23].
  567. %I - The 12 hour clock hour [01,12].
  568. %J - Replaced by the nanosecond [0,999999999].
  569. %j - The day of the year [001,366].
  570. %m - The month number [01,12].
  571. %M - The minute [00,59].
  572. %N - The microsecond [0,999999]
  573. %n - Any whitespace.
  574. %p - The equivalent of "AM" or "PM".
  575. %q - The millisecond [0,999].
  576. %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
  577. %R - Replaced by the time in 24 hour notation: "%H:%M".
  578. %S - The second [00,60].
  579. %t - Any white space.
  580. %T - Replaced by the time: "%H:%M:%S".
  581. %u - Replaced by the weekday number, with 1 representing Monday [1,7].
  582. %U - The week number of the year [00,53]. The first Sunday of January is
  583. the first day of week 1. Days before this are week 0.
  584. %w - The weekday number [0,6], with 0 representing Sunday.
  585. %W - The week number [00,53]. The first Monday of January is the first
  586. day of week 1. Days before this are in week 0.
  587. %x - Replaced by the locale's appropriate date representation.
  588. %X - Replaced by the locale's appropriate time representation.
  589. %y - The last two digits of the year [00,99].
  590. %Y - The full four digit year [0001,9999].
  591. %% - Replaced by a literal '%'.
  592. Time - Supplies a pointer to the calendar time value to place the
  593. values in. Only the values that are scanned in are modified.
  594. Return Value:
  595. Returns the a pointer to the input string after the last character scanned.
  596. NULL if the result coult not be scanned.
  597. --*/
  598. LIBC_API
  599. time_t
  600. time (
  601. time_t *Result
  602. );
  603. /*++
  604. Routine Description:
  605. This routine returns the current time in terms of seconds from the Epoch,
  606. midnight on January 1, 1970 GMT.
  607. Arguments:
  608. Result - Supplies an optional pointer where the current time will be
  609. returned. This will be the same as the return value.
  610. Return Value:
  611. Returns the current time since the epoch.
  612. --*/
  613. LIBC_API
  614. int
  615. timer_create (
  616. clockid_t ClockId,
  617. struct sigevent *Event,
  618. timer_t *TimerId
  619. );
  620. /*++
  621. Routine Description:
  622. This routine creates a new timer.
  623. Arguments:
  624. ClockId - Supplies the clock type ID. See CLOCK_* definitions. The most
  625. common value here is CLOCK_REALTIME.
  626. Event - Supplies a pointer to an event structure describing what should
  627. happen when the timer expires. If this parameter is NULL, then the
  628. timer will be treated as if this structure had specified that a
  629. SIGALRM signal should be generated with the timer ID number set as the
  630. signal value.
  631. TimerId - Supplies a pointer where the timer ID number will be returned on
  632. success.
  633. Return Value:
  634. 0 on success. The returned timer ID will be in the timer parameter.
  635. -1 on failure, and errno will be set to contain more information.
  636. --*/
  637. LIBC_API
  638. int
  639. timer_delete (
  640. timer_t TimerId
  641. );
  642. /*++
  643. Routine Description:
  644. This routine disarms and deletes the timer with the given ID.
  645. Arguments:
  646. TimerId - Supplies the ID of the timer to delete.
  647. Return Value:
  648. 0 on success.
  649. -1 on failure and errno will be set to EINVAL if the given timer handle is
  650. invalid.
  651. --*/
  652. LIBC_API
  653. int
  654. timer_gettime (
  655. timer_t TimerId,
  656. struct itimerspec *Value
  657. );
  658. /*++
  659. Routine Description:
  660. This routine gets the current timer information for the given timer.
  661. Arguments:
  662. TimerId - Supplies the ID of the timer to query.
  663. Value - Supplies a pointer where the remaining time on the timer will be
  664. returned.
  665. Return Value:
  666. 0 on success.
  667. -1 on failure and errno will be set to contain more information.
  668. --*/
  669. LIBC_API
  670. int
  671. timer_settime (
  672. timer_t TimerId,
  673. int Flags,
  674. const struct itimerspec *Value,
  675. struct itimerspec *OldValue
  676. );
  677. /*++
  678. Routine Description:
  679. This routine sets the current timer information for the given timer.
  680. Arguments:
  681. TimerId - Supplies the ID of the timer to set.
  682. Flags - Supplies a bitfield of flags. See TIMER_ABSTIME and friends.
  683. Value - Supplies a pointer where the remaining time on the timer will be
  684. returned.
  685. OldValue - Supplies an optional pointer where the structure containing the
  686. remaining time on the timer before this call will be returned.
  687. Return Value:
  688. 0 on success.
  689. -1 on failure and errno will be set to contain more information.
  690. --*/
  691. LIBC_API
  692. int
  693. timer_getoverrun (
  694. timer_t TimerId
  695. );
  696. /*++
  697. Routine Description:
  698. This routine returns the overrun count for the given timer. The overrun
  699. count can be queried during a signal, and represents the number of
  700. additional timer expiries that occurred before the signal was accepted by
  701. the process. If added to the count of signals that have occurred it
  702. represents the total number of expiries of the given periodic timer.
  703. Arguments:
  704. TimerId - Supplies the timer to query.
  705. Return Value:
  706. Returns the overrun count on success.
  707. -1 on failure, and errno will be set to contain more information.
  708. --*/
  709. LIBC_API
  710. void
  711. tzset (
  712. void
  713. );
  714. /*++
  715. Routine Description:
  716. This routine uses the values of the TZ environment variable to set time
  717. conversion information used by ctime, localtime, mktime, and strftime. If
  718. TZ is absent from the environment, a default timezone will be used.
  719. Arguments:
  720. None.
  721. Return Value:
  722. None.
  723. --*/
  724. LIBC_API
  725. int
  726. nanosleep (
  727. const struct timespec *RequestedTime,
  728. struct timespec *RemainingTime
  729. );
  730. /*++
  731. Routine Description:
  732. This routine suspends execution of the calling thread until either the
  733. given requested time elapses or a signal was delivered. If a signal was
  734. delivered, then the time remaining in the interval is reported.
  735. Arguments:
  736. RequestedTime - Supplies a pointer to the requested interval wait time.
  737. RemainingTime - Supplies an optional pointer that receives the time
  738. remaining in the interval if the routine is interrupted by a signal.
  739. Return Value:
  740. 0 on success.
  741. -1 on failure, and errno will be set to contain more information.
  742. --*/
  743. #ifdef __cplusplus
  744. }
  745. #endif
  746. #endif