rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 1 | .TH CTIME 3 |
| 2 | .SH NAME |
| 3 | ctime, localtime, gmtime, asctime, tm2sec, timezone \- convert date and time |
| 4 | .SH SYNOPSIS |
| 5 | .B #include <u.h> |
| 6 | .br |
| 7 | .B #include <libc.h> |
| 8 | .PP |
| 9 | .ta \w'\fLchar* 'u |
| 10 | .B |
| 11 | char* ctime(long clock) |
| 12 | .PP |
| 13 | .B |
| 14 | Tm* localtime(long clock) |
| 15 | .PP |
| 16 | .B |
| 17 | Tm* gmtime(long clock) |
| 18 | .PP |
| 19 | .B |
| 20 | char* asctime(Tm *tm) |
| 21 | .PP |
| 22 | .B |
| 23 | long tm2sec(Tm *tm) |
| 24 | .SH DESCRIPTION |
| 25 | .I Ctime |
| 26 | converts a time |
| 27 | .I clock |
| 28 | such as returned by |
| 29 | .IR time (3) |
| 30 | into |
| 31 | .SM ASCII |
| 32 | (sic) |
| 33 | and returns a pointer to a |
| 34 | 30-byte string |
| 35 | in the following form. |
| 36 | All the fields have constant width. |
| 37 | .PP |
| 38 | .B |
| 39 | Wed Aug 5 01:07:47 EST 1973\en\e0 |
| 40 | .PP |
| 41 | .I Localtime |
| 42 | and |
| 43 | .I gmtime |
| 44 | return pointers to structures containing |
| 45 | the broken-down time. |
| 46 | .I Localtime |
| 47 | corrects for the time zone and possible daylight savings time; |
| 48 | .I gmtime |
| 49 | converts directly to GMT. |
| 50 | .I Asctime |
| 51 | converts a broken-down time to |
| 52 | .SM ASCII |
| 53 | and returns a pointer |
| 54 | to a 30-byte string. |
| 55 | .IP |
| 56 | .EX |
| 57 | .ta 6n +\w'char 'u +\w'zone[4]; 'u |
| 58 | typedef |
| 59 | struct { |
| 60 | int sec; /* seconds (range 0..59) */ |
| 61 | int min; /* minutes (0..59) */ |
| 62 | int hour; /* hours (0..23) */ |
| 63 | int mday; /* day of the month (1..31) */ |
| 64 | int mon; /* month of the year (0..11) */ |
| 65 | int year; /* year A.D. \- 1900 */ |
| 66 | int wday; /* day of week (0..6, Sunday = 0) */ |
| 67 | int yday; /* day of year (0..365) */ |
| 68 | char zone[4]; /* time zone name */ |
| 69 | int tzoff; /* time zone delta from GMT */ |
| 70 | } Tm; |
| 71 | .EE |
| 72 | .PP |
| 73 | .I Tm2sec |
| 74 | converts a broken-down time to |
| 75 | seconds since the start of the epoch. |
| 76 | It ignores |
| 77 | .BR wday , |
| 78 | and assumes the local time zone |
| 79 | if |
| 80 | .B zone |
| 81 | is not |
| 82 | .BR GMT . |
| 83 | .SH SOURCE |
rsc | c3674de | 2005-01-11 17:37:33 +0000 | [diff] [blame] | 84 | .B \*9/src/lib9/date.c |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 85 | .br |
rsc | c3674de | 2005-01-11 17:37:33 +0000 | [diff] [blame] | 86 | .B \*9/src/lib9/ctime.c |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 87 | .SH "SEE ALSO" |
| 88 | .IR date (1), |
| 89 | .IR time (3) |
| 90 | .SH BUGS |
| 91 | The return values point to static data |
| 92 | whose content is overwritten by each call. |
rsc | c8b6342 | 2005-01-13 04:49:19 +0000 | [diff] [blame] | 93 | .PP |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 94 | Daylight Savings Time is ``normal'' in the Southern hemisphere. |
rsc | c8b6342 | 2005-01-13 04:49:19 +0000 | [diff] [blame] | 95 | .PP |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 96 | These routines are not equipped to handle non-\c |
| 97 | .SM ASCII |
| 98 | text, and are provincial anyway. |
rsc | c8b6342 | 2005-01-13 04:49:19 +0000 | [diff] [blame] | 99 | .PP |
| 100 | To avoid name conflicts with the underlying system, |
| 101 | .IR ctime , |
| 102 | .IR localtime , |
| 103 | .IR gmtime , |
| 104 | .IR asctime , |
| 105 | and |
| 106 | .I tm2sec |
| 107 | are preprocessor macros defined as |
| 108 | .IR p9ctime , |
| 109 | .IR p9localtime , |
| 110 | .IR p9gmtime , |
| 111 | .IR p9asctime , |
| 112 | and |
| 113 | .IR p9tm2sec ; |
| 114 | see |
| 115 | .IR intro (3). |