]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/time.h
Fix GCC build errors.
[mirror_edk2.git] / StdLib / Include / time.h
index 386629cc6b422ee216215cd97338db0a10a8c4b5..ecef1e2f6139409c67531a97730bc401cde1bb35 100644 (file)
     if Daylight Saving Time is not in effect, and negative if the information\r
     is not available.\r
 \r
-    Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+    The following macros are defined in this file:<BR>\r
+    @verbatim\r
+      NULL\r
+      CLOCKS_PER_SEC    The number of values per second returned by the clock function.\r
+    @endverbatim\r
+\r
+    The following types are defined in this file:<BR>\r
+    @verbatim\r
+      size_t      Unsigned integer type of the result of the sizeof operator.\r
+      clock_t     Arithmetic type capable of representing a time from the clock function.\r
+      time_t      Arithmetic type capable of representing a time.\r
+      struct tm   Holds the components of a calendar time; or broken-down time.\r
+    @endverbatim\r
+\r
+    The following functions are declared in this file:<BR>\r
+    @verbatim\r
+      ###############  Time Manipulation Functions\r
+      clock_t       clock     (void);\r
+      double        difftime  (time_t time1, time_t time0);\r
+      time_t        mktime    (struct tm *timeptr);\r
+      time_t        time      (time_t *timer);\r
+\r
+      #################  Time Conversion Functions\r
+      char        * asctime   (const struct tm *timeptr);\r
+      char        * ctime     (const time_t *timer);\r
+      struct tm   * gmtime    (const time_t *timer);\r
+      time_t        timegm    (struct tm*);\r
+      struct tm   * localtime (const time_t *timer);\r
+      size_t        strftime  (char * __restrict s, size_t maxsize,\r
+                               const char * __restrict format,\r
+                               const struct tm * __restrict timeptr);\r
+      char        * strptime  (const char *, const char * format, struct tm*);\r
+    @endverbatim\r
+\r
+    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
     This program and the accompanying materials are licensed and made available under\r
     the terms and conditions of the BSD License that accompanies this distribution.\r
     The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.php.\r
+    http://opensource.org/licenses/bsd-license.\r
 \r
     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
 **/\r
 #ifndef _TIME_H\r
 #define _TIME_H\r
   #undef _BSD_SIZE_T_\r
 #endif\r
 \r
-/** An arithmetic type capable of representing values returned by clock(); **/\r
 #ifdef _EFI_CLOCK_T\r
+  /** An arithmetic type capable of representing values returned by clock(); **/\r
   typedef _EFI_CLOCK_T  clock_t;\r
   #undef _EFI_CLOCK_T\r
 #endif\r
 \r
-/** An arithmetic type capable of representing values returned as calendar time\r
-    values, such as that returned by mktime();\r
-**/\r
 #ifdef _EFI_TIME_T\r
+  /** An arithmetic type capable of representing values returned as calendar time\r
+      values, such as that returned by mktime();\r
+  **/\r
   typedef _EFI_TIME_T  time_t;\r
   #undef _EFI_TIME_T\r
 #endif\r
 \r
+/** Value added to tm_year to get the full year value.  TM_YEAR_BASE + 110 --> 2010 **/\r
+#define TM_YEAR_BASE  1900\r
+\r
+/** @{\r
+    Values for the tm_wday member of struct tm.\r
+**/\r
+#define TM_SUNDAY     0\r
+#define TM_MONDAY     1\r
+#define TM_TUESDAY    2\r
+#define TM_WEDNESDAY  3\r
+#define TM_THURSDAY   4\r
+#define TM_FRIDAY     5\r
+#define TM_SATURDAY   6\r
+/*@}*/\r
+\r
+/** @{\r
+    Values for the tm_mon member of struct tm.\r
+**/\r
+#define TM_JANUARY     0\r
+#define TM_FEBRUARY    1\r
+#define TM_MARCH       2\r
+#define TM_APRIL       3\r
+#define TM_MAY         4\r
+#define TM_JUNE        5\r
+#define TM_JULY        6\r
+#define TM_AUGUST      7\r
+#define TM_SEPTEMBER   8\r
+#define TM_OCTOBER     9\r
+#define TM_NOVEMBER   10\r
+#define TM_DECEMBER   11\r
+/*@}*/\r
+\r
 /** A structure holding the components of a calendar time, called the\r
     broken-down time.  The first nine (9) members are as mandated by the\r
     C95 standard.  Additional fields have been added for EFI support.\r
 **/\r
 struct tm {\r
   int     tm_year;      // years since 1900\r
-  int     tm_mon;       // months since January \97 [0, 11]\r
-  int     tm_mday;      // day of the month \97 [1, 31]\r
-  int     tm_hour;      // hours since midnight \97 [0, 23]\r
-  int     tm_min;       // minutes after the hour \97 [0, 59]\r
-  int     tm_sec;       // seconds after the minute \97 [0, 60]\r
-  int     tm_wday;      // days since Sunday \97 [0, 6]\r
-  int     tm_yday;      // days since January 1 \97 [0, 365]\r
+  int     tm_mon;       // months since January  [0, 11]\r
+  int     tm_mday;      // day of the month  [1, 31]\r
+  int     tm_hour;      // hours since midnight  [0, 23]\r
+  int     tm_min;       // minutes after the hour  [0, 59]\r
+  int     tm_sec;       // seconds after the minute  [0, 60]\r
+  int     tm_wday;      // days since Sunday  [0, 6]\r
+  int     tm_yday;      // days since January 1  [0, 365]\r
   int     tm_isdst;     // Daylight Saving Time flag\r
   int     tm_zoneoff;   // EFI TimeZone offset, -1440 to 1440 or 2047\r
   int     tm_daylight;  // EFI Daylight flags\r
@@ -92,7 +157,7 @@ struct tm {
 \r
 /** The clock function determines the processor time used.\r
 \r
-    @return   The clock function returns the implementation\92s best\r
+    @return   The clock function returns the implementation's best\r
               approximation to the processor time used by the program since the\r
               beginning of an implementation-defined era related only to the\r
               program invocation.  To determine the time in seconds, the value\r
@@ -100,55 +165,110 @@ struct tm {
               the macro CLOCKS_PER_SEC.  If the processor time used is not\r
               available or its value cannot be represented, the function\r
               returns the value (clock_t)(-1).\r
-\r
-              On IA32 or X64 platforms, the value returned is the number of\r
-              CPU TimeStamp Counter ticks since the appliation started.\r
 **/\r
-clock_t EFIAPI clock(void);\r
+clock_t  clock(void);\r
 \r
-/**\r
+/** Compute the difference between two calendar times: time1 - time0.\r
+\r
+    @param[in]  time1   An arithmetic calendar time.\r
+    @param[in]  time2   Another arithmetic calendar time.\r
+\r
+    @return   The difference between the two times expressed in seconds.\r
 **/\r
-double EFIAPI difftime(time_t time1, time_t time0);\r
+double difftime(time_t time1, time_t time0);\r
 \r
-/** The mktime function converts the broken-down time, expressed as local time,\r
+/** Convert a broken-down time into an arithmetic calendar time.\r
+\r
+    The mktime function converts the broken-down time, expressed as local time,\r
     in the structure pointed to by timeptr into a calendar time value with the\r
     same encoding as that of the values returned by the time function. The\r
     original values of the tm_wday and tm_yday components of the structure are\r
     ignored, and the original values of the other components are not\r
-    restricted to the ranges indicated above.270) On successful completion,\r
+    restricted to the ranges indicated above. On successful completion,\r
     the values of the tm_wday and tm_yday components of the structure are set\r
     appropriately, and the other components are set to represent the specified\r
     calendar time, but with their values forced to the ranges indicated above;\r
     the final value of tm_mday is not set until tm_mon and tm_year\r
     are determined.\r
 \r
+    @param[in]  timeptr   Pointer to a broken-down time to be converted.\r
+\r
     @return   The mktime function returns the specified calendar time encoded\r
               as a value of type time_t. If the calendar time cannot be\r
               represented, the function returns the value (time_t)(-1).\r
 **/\r
-time_t EFIAPI mktime(struct tm *timeptr);\r
+time_t mktime(struct tm *timeptr);\r
+\r
+/** The time function determines the current calendar time.\r
+\r
+    The encoding of the value is unspecified and undocumented.\r
+\r
+    @param[out]   timer   An optional pointer to an object in which to\r
+                          store the calendar time.\r
 \r
-/**\r
+    @return   The time function returns the implementation's best approximation\r
+              of the current calendar time. The value (time_t)(-1) is returned\r
+              if the calendar time is not available. If timer is not a null\r
+              pointer, the return value is also assigned to the object it\r
+              points to.\r
 **/\r
-time_t EFIAPI time(time_t *timer);\r
+time_t time(time_t *timer);\r
 \r
 /* #################  Time Conversion Functions  ########################## */\r
 \r
-/**\r
+/** The asctime function converts the broken-down time in the structure pointed\r
+    to by timeptr into a string in the form<BR>\r
+    @verbatim\r
+          Sun Sep 16 01:03:52 1973\n\0\r
+    @endverbatim\r
+\r
+    @param[in]  timeptr   A pointer to a broken-down time to convert.\r
+\r
+    @return   The asctime function returns a pointer to the string.\r
 **/\r
-char * EFIAPI asctime(const struct tm *timeptr);\r
+char * asctime(const struct tm *timeptr);\r
+\r
+/** The ctime function converts the calendar time pointed to by timer to a local\r
+    time in the form of a string. It is equivalent to asctime(localtime(timer))\r
+\r
+    @param[in]  timer   Pointer to a calendar time value to convert into a\r
+                        string representation.\r
+\r
+    @return   The ctime function returns the pointer returned by the asctime\r
+              function with that broken-down time as argument.\r
+**/\r
+char * ctime(const time_t *timer);\r
+\r
+/** The gmtime function converts the calendar time pointed to by timer into a\r
+    broken-down time, expressed as UTC.\r
 \r
-/**\r
+    @param[in]  timer   Pointer to a calendar time value to convert into a\r
+                        broken-down time.\r
+\r
+    @return   The gmtime function returns a pointer to the broken-down time,\r
+              or a null pointer if the specified time cannot be converted to UTC.\r
 **/\r
-char * EFIAPI ctime(const time_t *timer);\r
+struct tm  * gmtime(const time_t *timer);\r
+\r
+/** The timegm function is the opposite of gmtime.\r
 \r
-/**\r
+    @param[in]  tm    Pointer to a broken-down time to convert into a\r
+                      calendar time.\r
+\r
+    @return   The calendar time expressed as UTC.\r
 **/\r
-struct tm  * EFIAPI gmtime(const time_t *timer);\r
+time_t timegm(struct tm*);\r
+\r
+/** The localtime function converts the calendar time pointed to by timer into\r
+    a broken-down time, expressed as local time.\r
 \r
-/**\r
+    @param[in]  timer   Pointer to a calendar time value to be converted.\r
+\r
+    @return   The localtime function returns a pointer to the broken-down time,\r
+              or a null pointer if the specified time cannot be converted to\r
+              local time.\r
 **/\r
-struct tm  * EFIAPI localtime(const time_t *timer);\r
+struct tm  * localtime(const time_t *timer);\r
 \r
 /** The strftime function places characters into the array pointed to by s as\r
     controlled by the string pointed to by format. The format shall be a\r
@@ -170,11 +290,11 @@ struct tm  * EFIAPI localtime(const time_t *timer);
     in the description. If any of the specified values is outside the normal\r
     range, the characters stored are unspecified.\r
 \r
-    %a is replaced by the locale\92s abbreviated weekday name. [tm_wday]\r
-    %A is replaced by the locale\92s full weekday name. [tm_wday]\r
-    %b is replaced by the locale\92s abbreviated month name. [tm_mon]\r
-    %B is replaced by the locale\92s full month name. [tm_mon]\r
-    %c is replaced by the locale\92s appropriate date and time representation.\r
+    %a is replaced by the locale's abbreviated weekday name. [tm_wday]\r
+    %A is replaced by the locale's full weekday name. [tm_wday]\r
+    %b is replaced by the locale's abbreviated month name. [tm_mon]\r
+    %B is replaced by the locale's full month name. [tm_mon]\r
+    %c is replaced by the locale's appropriate date and time representation.\r
     %C is replaced by the year divided by 100 and truncated to an integer,\r
        as a decimal number (00-99). [tm_year]\r
     %d is replaced by the day of the month as a decimal number (01-31). [tm_mday]\r
@@ -194,9 +314,9 @@ struct tm  * EFIAPI localtime(const time_t *timer);
     %m is replaced by the month as a decimal number (01-12). [tm_mon]\r
     %M is replaced by the minute as a decimal number (00-59). [tm_min]\r
     %n is replaced by a new-line character.\r
-    %p is replaced by the locale\92s equivalent of the AM/PM designations\r
+    %p is replaced by the locale's equivalent of the AM/PM designations\r
        associated with a 12-hour clock. [tm_hour]\r
-    %r is replaced by the locale\92s 12-hour clock time. [tm_hour, tm_min, tm_sec]\r
+    %r is replaced by the locale's 12-hour clock time. [tm_hour, tm_min, tm_sec]\r
     %R is equivalent to "%H:%M". [tm_hour, tm_min]\r
     %S is replaced by the second as a decimal number (00-60). [tm_sec]\r
     %t is replaced by a horizontal-tab character.\r
@@ -212,8 +332,8 @@ struct tm  * EFIAPI localtime(const time_t *timer);
        [tm_wday]\r
     %W is replaced by the week number of the year (the first Monday as the\r
        first day of week 1) as a decimal number (00-53). [tm_year, tm_wday, tm_yday]\r
-    %x is replaced by the locale\92s appropriate date representation.\r
-    %X is replaced by the locale\92s appropriate time representation.\r
+    %x is replaced by the locale's appropriate date representation.\r
+    %X is replaced by the locale's appropriate time representation.\r
     %y is replaced by the last 2 digits of the year as a decimal\r
        number (00-99). [tm_year]\r
     %Y is replaced by the year as a decimal number (e.g., 1997). [tm_year]\r
@@ -227,38 +347,38 @@ struct tm  * EFIAPI localtime(const time_t *timer);
     Some conversion specifiers can be modified by the inclusion of an E or O\r
     modifier character to indicate an alternative format or specification.\r
     If the alternative format or specification does not exist for the current\r
-    locale, the modifier is ignored. %Ec is replaced by the locale\92s\r
+    locale, the modifier is ignored. %Ec is replaced by the locale's\r
     alternative date and time representation.\r
 \r
-    %EC is replaced by the name of the base year (period) in the locale\92s\r
+    %EC is replaced by the name of the base year (period) in the locale's\r
         alternative representation.\r
-    %Ex is replaced by the locale\92s alternative date representation.\r
-    %EX is replaced by the locale\92s alternative time representation.\r
-    %Ey is replaced by the offset from %EC (year only) in the locale\92s\r
+    %Ex is replaced by the locale's alternative date representation.\r
+    %EX is replaced by the locale's alternative time representation.\r
+    %Ey is replaced by the offset from %EC (year only) in the locale's\r
         alternative representation.\r
-    %EY is replaced by the locale\92s full alternative year representation.\r
-    %Od is replaced by the day of the month, using the locale\92s alternative\r
+    %EY is replaced by the locale's full alternative year representation.\r
+    %Od is replaced by the day of the month, using the locale's alternative\r
         numeric symbols (filled as needed with leading zeros, or with leading\r
         spaces if there is no alternative symbol for zero).\r
-    %Oe is replaced by the day of the month, using the locale\92s alternative\r
+    %Oe is replaced by the day of the month, using the locale's alternative\r
         numeric symbols (filled as needed with leading spaces).\r
-    %OH is replaced by the hour (24-hour clock), using the locale\92s\r
+    %OH is replaced by the hour (24-hour clock), using the locale's\r
         alternative numeric symbols.\r
-    %OI is replaced by the hour (12-hour clock), using the locale\92s\r
+    %OI is replaced by the hour (12-hour clock), using the locale's\r
         alternative numeric symbols.\r
-    %Om is replaced by the month, using the locale\92s alternative numeric symbols.\r
-    %OM is replaced by the minutes, using the locale\92s alternative numeric symbols.\r
-    %OS is replaced by the seconds, using the locale\92s alternative numeric symbols.\r
-    %Ou is replaced by the ISO 8601 weekday as a number in the locale\92s\r
+    %Om is replaced by the month, using the locale's alternative numeric symbols.\r
+    %OM is replaced by the minutes, using the locale's alternative numeric symbols.\r
+    %OS is replaced by the seconds, using the locale's alternative numeric symbols.\r
+    %Ou is replaced by the ISO 8601 weekday as a number in the locale's\r
         alternative representation, where Monday is 1.\r
-    %OU is replaced by the week number, using the locale\92s alternative numeric symbols.\r
-    %OV is replaced by the ISO 8601 week number, using the locale\92s alternative\r
+    %OU is replaced by the week number, using the locale's alternative numeric symbols.\r
+    %OV is replaced by the ISO 8601 week number, using the locale's alternative\r
         numeric symbols.\r
-    %Ow is replaced by the weekday as a number, using the locale\92s alternative\r
+    %Ow is replaced by the weekday as a number, using the locale's alternative\r
         numeric symbols.\r
-    %OW is replaced by the week number of the year, using the locale\92s\r
+    %OW is replaced by the week number of the year, using the locale's\r
         alternative numeric symbols.\r
-    %Oy is replaced by the last 2 digits of the year, using the locale\92s\r
+    %Oy is replaced by the last 2 digits of the year, using the locale's\r
         alternative numeric symbols.\r
 \r
     %g, %G, and %V give values according to the ISO 8601 week-based year. In\r
@@ -300,12 +420,15 @@ struct tm  * EFIAPI localtime(const time_t *timer);
               character. Otherwise, zero is returned and the contents of the\r
               array are indeterminate.\r
 **/\r
-size_t EFIAPI strftime( char * __restrict s, size_t maxsize,\r
+size_t strftime( char * __restrict s, size_t maxsize,\r
                       const char * __restrict format,\r
                       const struct tm * __restrict timeptr);\r
 \r
+char *strptime(const char *, const char * format, struct tm*);\r
+\r
+\r
 /* #################  Implementation Functions  ########################### */\r
 \r
-clock_t EFIAPI __getCPS(void);\r
+clock_t __getCPS(void);\r
 \r
 #endif  /* _TIME_H */\r