Commit | Line | Data |
---|---|---|
463d6749 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
5 | .\" @(#)ctime.3 4.1 (Berkeley) %G% | |
6 | .\" | |
7 | .TH CTIME 3 | |
8 | .UC 4 | |
9 | .SH NAME | |
10 | ctime, localtime, gmtime, asctime, timezone \- convert date and time to ASCII | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .B char *ctime(clock) | |
14 | .B long *clock; | |
15 | .PP | |
16 | .B #include <time.h> | |
17 | .PP | |
18 | .B struct tm *localtime(clock) | |
19 | .B long *clock; | |
20 | .PP | |
21 | .B struct tm *gmtime(clock) | |
22 | .B long *clock; | |
23 | .PP | |
24 | .B char *asctime(tm) | |
25 | .B struct tm *tm; | |
26 | .PP | |
27 | .B char *timezone(zone, dst) | |
28 | .fi | |
29 | .SH DESCRIPTION | |
30 | .I Ctime | |
31 | converts a time pointed to by | |
32 | .I clock | |
33 | such as returned by | |
34 | .IR time (2) | |
35 | into ASCII | |
36 | and returns a pointer to a | |
37 | 26-character string | |
38 | in the following form. | |
39 | All the fields have constant width. | |
40 | .PP | |
41 | Sun Sep 16 01:03:52 1973\\n\\0 | |
42 | .PP | |
43 | .I Localtime | |
44 | and | |
45 | .I gmtime | |
46 | return pointers to structures containing | |
47 | the broken-down time. | |
48 | .I Localtime | |
49 | corrects for the time zone and possible daylight savings time; | |
50 | .I gmtime | |
51 | converts directly to GMT, which is the time UNIX uses. | |
52 | .I Asctime | |
53 | converts a broken-down time to ASCII and returns a pointer | |
54 | to a 26-character string. | |
55 | .PP | |
56 | The structure declaration from the include file is: | |
57 | .RS | |
58 | .PP | |
59 | .nf | |
60 | .so /usr/include/time.h | |
61 | .fi | |
62 | .RE | |
63 | .PP | |
64 | These quantities give the time on a 24-hour clock, | |
65 | day of month (1-31), month of year (0-11), day of week | |
66 | (Sunday = 0), year \- 1900, day of year (0-365), | |
67 | and a flag that is nonzero if daylight saving time is in effect. | |
68 | .PP | |
69 | When local time is called for, | |
70 | the program consults the system to determine the time zone and | |
71 | whether the standard U.S.A. daylight saving time adjustment is | |
72 | appropriate. | |
73 | The program knows about the peculiarities | |
74 | of this conversion in 1974 and 1975; | |
75 | if necessary, | |
76 | a table for these years can be extended. | |
77 | .PP | |
78 | .I Timezone | |
79 | returns the name of the time zone associated with its first argument, | |
80 | which is measured in minutes westward from Greenwich. | |
81 | If the second argument is 0, the standard name is used, | |
82 | otherwise the Daylight Saving version. | |
83 | If the required name does not appear in a table | |
84 | built into the routine, | |
85 | the difference from GMT is produced; e.g. | |
86 | in Afghanistan | |
87 | .I timezone(-(60*4+30), 0) | |
88 | is appropriate because it is 4:30 ahead of GMT | |
89 | and the string | |
90 | .B GMT+4:30 | |
91 | is produced. | |
92 | .SH "SEE ALSO" | |
93 | time(2) | |
94 | .SH BUGS | |
95 | The return values point to static data | |
96 | whose content is overwritten by each call. |