| Previous | Contents | Index |
The <time.h> header file defines two macros, and declares four types and several functions for manipulating time and date information. Some functions process local time, which may differ from calendar time because of time zone.
clock_t time_t |
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 -- 0 if */
/* DST not in effect; positive if it is; */
/* negative if information is not available. */
|
char *asctime(const struct tm *timeptr);
Sat Sep 08 08:10:32 1990\n\0 |
char *ctime(const time_t *timer);
asctime(localtime(timer)) |
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);
size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr);
| Specifier | Replaced by |
|---|---|
| %a | The locale's abbreviated weekday name |
| %A | The locale's full weekday name |
| %b | The locale's abbreviated month name |
| %B | The locale's full month name |
| %c | The locale's appropriate date and time representation |
| %d | The day of the month as a decimal number (01 -- 31) |
| %H | The hour (24-hour clock) as a decimal number (00 -- 23) |
| %I | The hour (12-hour clock) as a decimal number (01 -- 12) |
| %j | The day of the year as a decimal number (001 -- 366) |
| %m | The month as a decimal number (01 -- 12) |
| %M | The minute as a decimal number (00 -- 59) |
| %p | The locale's equivalent of the AM/PM designations associated with a 12-hour clock |
| %S | The second as a decimal number (00 -- 61) |
| %U | The week number of the year (the first Sunday as the first day of week 1) as a decimal number (00 -- 53) |
| %w | The weekday as a decimal number (0 [Sunday] -- 6) |
| %W | The week number of the year (the first Monday as the first day of week 1) as a decimal number (00 -- 53) |
| %x | The locale's appropriate date representation |
| %X | The locale's appropriate time representation |
| %y | The year without century as a decimal number (00 -- 99) |
| %Y | The year with century as a decimal number |
| %Z | The time zone name or abbreviation, or by no characters if no time zone can be determined |
| %% | % |
double difftime(time_t time1, time_t time0);
time_t mktime(struct tm *timeptr);
This section summarizes the syntax of the C language, using the syntax of the ANSI C Standard. Syntactic categories are indicated with bold type, and literal words or characters are indicated with monospaced, nonitalicized type. A colon following a syntactic category introduces its definition. Alternative definitions are listed on separate lines, or are prefaced by the words "one of." An optional element is indicated by the subscript opt. For example, the following line indicates an optional expression enclosed in braces:
|
{ expressionopt } |
The section numbers shown in parentheses refer to the section of the American National Standard for Information Systems-Programming Language C (document number: X3.159-1989) that discusses that part of the language.
token: (§3.1)
|
preprocessing-token: (§3.1)
|
keyword: (§3.1.1) one of
|
|
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
|
identifier: (§3.1.2)
|
nondigit: §3.1.2 one of
|
|
a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z _
|
digit: (§3.1.2) one of
|
|
0 1 2 3 4 5 6 7 8 9
|
constant: (§3.1.3)
|
floating-constant: (§3.1.3.1)
|
fractional-constant: (§3.1.3.1)
|
exponent-part: (§3.1.3.1)
|
sign: (§3.1.3.1) one of
|
digit-sequence: (§3.1.3.1)
|
floating-suffix: (§3.1.3.1) one of
|
|
integer-constant: (§3.1.3.2)
|
decimal-constant: (§3.1.3.2)
|
octal-constant: (§3.1.3.2)
|
hexadecimal-constant: (§3.1.3.2)
|
nonzero-digit: (§3.1.3.2) one of
|
|
1 2 3 4 5 6 7 8 9
|
octal-digit: (§3.1.3.2) one of
|
|
0 1 2 3 4 5 6 7
|
hexadecimal-digit: (§3.1.3.2) one of
|
|
0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F
|
integer-suffix: (§3.1.3.2)
|
unsigned-suffix: (§3.1.3.2) one of
|
|
long-suffix: (§3.1.3.2) one of
|
|
enumeration-constant: (§3.1.3.3)
|
character-constant: (§3.1.3.4)
|
c-char-sequence: (§3.1.3.4)
|
c-char: (§3.1.3.4)
|
escape-sequence: (§3.1.3.4)
|
simple-escape-sequence: (§3.1.3.4) one of
|
|
\' \" \? \\
\a \b \f \n \r \t \v
|
octal-escape-sequence: (§3.1.3.4)
|
hexadecimal-escape-sequence:(§3.1.3.4)
|
string-literal: (§3.1.4)
|
s-char-sequence: (§3.1.4)
|
s-char: (§3.1.4)
|
operator: (§3.1.5) one of
|
|
[ ] ( ) . ->
++ -- & * + - ~ ! sizeof
/ % << >> < > <= >= == != ^ | && ||
? :
= *= /= %= += -= <<= >>= &= ^= |=
, # ##
|
punctuator: (§3.1.6) one of
|
|
[ ] ( ) { } * , : = ; ... #
|
header-name: (§3.1.7)
|
h-char-sequence: (§3.1.7)
|
h-char: (§3.1.7)
|
q-char-sequence: (§3.1.7)
|
q-char: (§3.1.7)
|
pp-number: (§3.1.8)
|
A.1.2 Phrase Structure Grammar
primary-expression: (§3.3.1)
|
postfix-expression: (§3.3.2)
|
| Previous | Next | Contents | Index |