2000-02-18 03:39:52 +08:00
|
|
|
@node Timefns
|
|
|
|
@chapter Time Functions (@file{time.h})
|
|
|
|
|
|
|
|
This chapter groups functions used either for reporting on time
|
|
|
|
(elapsed, current, or compute time) or to perform calculations based
|
|
|
|
on time.
|
|
|
|
|
|
|
|
The header file @file{time.h} defines three types. @code{clock_t} and
|
|
|
|
@code{time_t} are both used for representations of time particularly
|
|
|
|
suitable for arithmetic. (In this implementation, quantities of type
|
|
|
|
@code{clock_t} have the highest resolution possible on your machine,
|
|
|
|
and quantities of type @code{time_t} resolve to seconds.) @code{size_t}
|
|
|
|
is also defined if necessary for quantities representing sizes.
|
|
|
|
|
|
|
|
@file{time.h} also defines the structure @code{tm} for the traditional
|
|
|
|
representation of Gregorian calendar time as a series of numbers, with
|
|
|
|
the following fields:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item tm_sec
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Seconds, between 0 and 60 inclusive (60 allows for leap seconds).
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_min
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Minutes, between 0 and 59 inclusive.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_hour
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Hours, between 0 and 23 inclusive.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_mday
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Day of the month, between 1 and 31 inclusive.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_mon
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Month, between 0 (January) and 11 (December).
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_year
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Year (since 1900), can be negative for earlier years.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_wday
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Day of week, between 0 (Sunday) and 6 (Saturday).
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_yday
|
2005-02-16 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).
2005-02-17 05:15:37 +08:00
|
|
|
Number of days elapsed since last January 1, between 0 and 365 inclusive.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@item tm_isdst
|
|
|
|
Daylight Savings Time flag: positive means DST in effect, zero means DST
|
|
|
|
not in effect, negative means no information about DST is available.
|
2009-03-09 20:35:03 +08:00
|
|
|
Although for mktime(), negative means that it should decide if DST is in
|
|
|
|
effect or not.
|
2000-02-18 03:39:52 +08:00
|
|
|
@end table
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* asctime:: Format time as string
|
|
|
|
* clock:: Cumulative processor time
|
|
|
|
* ctime:: Convert time to local and format as string
|
|
|
|
* difftime:: Subtract two times
|
|
|
|
* gmtime:: Convert time to UTC (GMT) traditional representation
|
|
|
|
* localtime:: Convert time to local representation
|
|
|
|
* mktime:: Convert time to arithmetic representation
|
2009-03-09 20:35:03 +08:00
|
|
|
* strftime:: Convert date and time to a user-formatted string
|
2000-02-18 03:39:52 +08:00
|
|
|
* time:: Get current calendar time (as single number)
|
2004-09-17 05:15:14 +08:00
|
|
|
* __tz_lock:: Lock time zone global variables
|
2002-04-18 05:37:07 +08:00
|
|
|
* tzset:: Set timezone info
|
2000-02-18 03:39:52 +08:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/asctime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/clock.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/ctime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/difftime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/gmtime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/lcltime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/mktime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/strftime.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include time/time.def
|
2002-04-18 05:37:07 +08:00
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include time/tzlock.def
|
|
|
|
|
2002-04-18 05:37:07 +08:00
|
|
|
@page
|
|
|
|
@include time/tzset.def
|