plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

ctime.3 (2109B)


      1 .TH CTIME 3
      2 .SH NAME
      3 ctime, localtime, gmtime, asctime, tm2sec \- 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 .MR 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
     84 .B \*9/src/lib9/ctime.c
     85 .br
     86 .B \*9/src/lib9/tm2sec.c
     87 .SH "SEE ALSO"
     88 .MR date (1) ,
     89 .MR time (3)
     90 .SH BUGS
     91 The return values point to static data
     92 whose content is overwritten by each call.
     93 .PP
     94 Daylight Savings Time is ``normal'' in the Southern hemisphere.
     95 .PP
     96 These routines are not equipped to handle non-\c
     97 .SM ASCII
     98 text, and are provincial anyway.
     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 .MR intro (3) .