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 | .\" | |
2ad48aae | 5 | .\" @(#)ctime.3 6.3 (Berkeley) %G% |
463d6749 | 6 | .\" |
3f00558b | 7 | .TH CTIME 3 "" |
463d6749 KM |
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 | |
2ad48aae | 16 | .B #include <time.h> |
463d6749 KM |
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: | |
463d6749 | 57 | .PP |
8eafd288 | 58 | .RS |
463d6749 | 59 | .nf |
5f90d5f0 KM |
60 | .nr .0 .8i+\w'int tm_isdst'u |
61 | .ta .5i \n(.0u \n(.0u+\w'/* 0-000'u+1n | |
8eafd288 | 62 | struct tm { |
5f90d5f0 KM |
63 | int tm_sec; /* 0-59 seconds */ |
64 | int tm_min; /* 0-59 minutes */ | |
65 | int tm_hour; /* 0-23 hour */ | |
66 | int tm_mday; /* 1-31 day of month */ | |
67 | int tm_mon; /* 0-11 month */ | |
68 | int tm_year; /* 0- year \- 1900 */ | |
69 | int tm_wday; /* 0-6 day of week (Sunday = 0) */ | |
70 | int tm_yday; /* 0-365 day of year */ | |
71 | int tm_isdst; /* flag: daylight savings time in effect */ | |
8eafd288 | 72 | }; |
463d6749 KM |
73 | .fi |
74 | .RE | |
75 | .PP | |
463d6749 KM |
76 | When local time is called for, |
77 | the program consults the system to determine the time zone and | |
8eafd288 KM |
78 | whether the U.S.A., Australian, Eastern European, Middle European, |
79 | or Western European daylight saving time adjustment is appropriate. | |
80 | The program knows about various peculiarities in time conversion | |
81 | over the past 10-20 years; if necessary, this understanding can | |
82 | be extended. | |
463d6749 KM |
83 | .PP |
84 | .I Timezone | |
85 | returns the name of the time zone associated with its first argument, | |
86 | which is measured in minutes westward from Greenwich. | |
87 | If the second argument is 0, the standard name is used, | |
88 | otherwise the Daylight Saving version. | |
89 | If the required name does not appear in a table | |
90 | built into the routine, | |
91 | the difference from GMT is produced; e.g. | |
92 | in Afghanistan | |
93 | .I timezone(-(60*4+30), 0) | |
94 | is appropriate because it is 4:30 ahead of GMT | |
95 | and the string | |
96 | .B GMT+4:30 | |
97 | is produced. | |
98 | .SH "SEE ALSO" | |
8eafd288 | 99 | gettimeofday(2), time(3) |
463d6749 KM |
100 | .SH BUGS |
101 | The return values point to static data | |
102 | whose content is overwritten by each call. |