TCPL/B.10_Date_and_Time_Functions:_<time.h>

<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

B.10 Date and Time Functions: <time.h>

The header <time.h> declares types and functions for manipulating date and time. Some functions process local time, which may differ from calendar time, for example because of time zone. clock_t and time_t are arithmetic types representing times, and struct tm holds the components of a calendar time:

int tm_sec;     seconds after the minute (0,61)
int tm_min;     minutes after the hour (0,59)
int tm_hour;    hours since midnight (0,23)
int tm_mday;    day of the month (1,31)
int tm_mon;     months since January (0,11)
int tm_year;    years since 1900
int tm_wday;    days since Sunday (0,6)
int tm_yday;    days since January 1 (0,365)
int tm_isdst;   Daylight Saving Time flag

tm_isdst is positive if Daylight Saving Time is in effect, zero if not, and negative if the information is not available.

clock_t clock(void)

time_t time(time_t *tp)

double difftime(time_t time2, time_t time1)

time_t mktime(struct tm *tp)

The next four functions return pointers to static objects that may be overwritten by other calls.

char *asctime(const struct tm *tp)

char *ctime(const time_t *tp)

struct tm *gmtime(const time_t *tp)

struct tm *localtime(const time_t *tp)

size_t strftime(char *s, size_t smax, const char *fmt, const struct tm *tp)

%a      abbreviated weekday name.
%A      full weekday name.
%b      abbreviated month name.
%B      full month name.
%c      local date and time representation.
%d      day of the month (01-31).
%H      hour (24-hour clock) (00-23).
%I      hour (12-hour clock) (01-12).
%j      day of the year (001-366).
%m      month (01-12).
%M      minute (00-59).
%p      local equivalent of AM or PM.
%S      second (00-61).
%U      week number of the year (Sunday as 1st day of week) (00-53).
%w      weekday (0-6, Sunday is 0).
%W      week number of the year (Monday as 1st day of week) (00-53).
%x      local date representation.
%X      local time representation.
%y      year without century (00-99).
%Y      year with century.
%Z      time zone name, if any.
%%      %

TCPL/B.10_Date_and_Time_Functions:_<time.h> (2008-02-23 15:36:53由localhost编辑)