forsyth20121205-174063a80cc13 years agoHistory
145 lines · 3.6 KB · Text
RawDownload
.TH DAYTIME 2.SH NAMEdaytime: text, filet, gmt, local, now, string2tm, time, tm2epoch \- time conversions.SH SYNOPSIS.EXinclude "daytime.m";daytime := load Daytime Daytime->PATH; Tm: adt{    sec:    int;    # seconds (0 to 59)    min:    int;    # minutes (0 to 59)    hour:   int;    # hours (0 to 23)    mday:   int;    # day of the month (1 to 31)    mon:    int;    # month (0 to 11)    year:   int;    # year-1900; 2000AD is 100    wday:   int;    # day of week (0 to 6, Sunday is 0)    yday:   int;    # day of year (0 to 365)    zone:   string; # time zone name    tzoff:  int;    # time zone offset (seconds from GMT)}; text:      fn(tm: ref Tm): string;filet:     fn(now, t: int): string;gmt:       fn(tim: int): ref Tm;local:     fn(tim: int): ref Tm;now:       fn(): int;time:      fn(): string;tm2epoch:  fn(tm: ref Tm): int;string2tm: fn(date: string): ref Tm;.EE.SH DESCRIPTIONThese routines perform time conversions relative to theepoch 00:00:00 GMT, Jan. 1, 1970.Note the range of values for each member of the.B Tmadt.The conventions are the same as those of C's.IR ctime ..PP.B Textconverts a time structure referenced by.I tmfrom local or GMT time to a string in the format:.IP.B "Sat Jan  1 13:00:00 GMT 2000".PP.B Filetconverts the file access or modification time.I tfrom seconds since the epoch to local time as a stringin the format:.IP.B "Jan  1 13:00".PPif the file is less than 6 months old or.IP.B "Jan  1 2000".PPif the file is older than 6 months, compared to the time.IR now ..PP.B Gmtconverts seconds since the epoch, received in.IR tim ,to a time structure in Greenwich Mean Time (GMT)..PP.B Localconverts seconds since the epoch, received in.IR tim ,to a time structure in local time..PP.B Nowreturns the time in seconds since the epoch, obtained by reading.B /dev/time(see.IR cons (3))..PP.B Timeconverts seconds since the epochto the local time as a string in the format.BR "Fri May 19 17:01:36 BST 2000" ..PP.B Tm2epochconverts a time structure referenced by.I tmfrom local or GMT time to seconds since the epoch..PP.B String2tmreturns a reference to a.B Tmvalue corresponding to the date and time in textual form in string.IR s ,which must have one of the forms below:.IP.EXSun, 06 Nov 1994 08:49:37 GMT    \fR(RFC822, RFC1123)\fPSunday, 06-Nov-94 08:49:37 GMT   \fR(RFC850)\fPSun Nov  6 08:49:37 GMT 1994     \fR(output of \fPtext\fR, above)\fP.EE.PPA missing time zone in any format is assumed to be.BR GMT ..B String2tmreturns nil if.I sis not correctly formed..PPWhen local time is first requested,.B daytimereads a table for time zone conversion from the.B timezoneenvironment variable, if that is set,and otherwise from the file.BR /locale/timezone ,which is copied from one of the other files in.B /localewhen the system is installed.The timezone table is a text file containing lines of space-separated fields.The first line gives the normal time zone name and its difference from GMTin seconds followed by an alternative time zone name (eg, for `daylight savings' or `summer' time) andits difference from GMT followed by a newline.The remainder is a list of pairs of times(seconds past the start of 1970, in the first time zone)when the alternative time zone applies.For example:.IP.EXEST -18000 EDT -14400 9943200 25664400 41392800 57718800 ....EE.PPGreenwich Mean Time is represented by.IP.EXGMT 0.EE.SH SOURCE.B /appl/lib/daytime.b.SH SEE ALSO.IR cons (3),.IR sys-millisec (2).SH BUGSThe sign bit of a Limbo integer holding a time will turn on 68 years from theepoch.