diff options
| author | Charles.Forsyth <devnull@localhost> | 2007-09-01 14:43:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2007-09-01 14:43:39 +0000 |
| commit | 4252603c74a95023984422e8cc3520cc3d9340ac (patch) | |
| tree | 80b7d96db673b3f6d767e40ba1c92a346980fae6 | |
| parent | 6fe7bebd2f2f6637660b1b20674622b1eeaf6180 (diff) | |
20070901-1541
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | appl/lib/daytime.b | 24 | ||||
| -rw-r--r-- | dis/lib/daytime.dis | bin | 4534 -> 4701 bytes | |||
| -rw-r--r-- | man/2/INDEX | 1 | ||||
| -rw-r--r-- | man/2/daytime | 45 |
5 files changed, 55 insertions, 17 deletions
@@ -1,3 +1,5 @@ +20070902 + make /appl/lib/daytime.b accept Daytime->text's output; add string2tm to man page (issue 59) 20070901 add andrey's changes to emu/MacOSX/win.c (used by emu/MacOSX/mkfile-a) add saoret's changes to dis/lookman, dis/man (issue 58) diff --git a/appl/lib/daytime.b b/appl/lib/daytime.b index a650f8ca..0e16073b 100644 --- a/appl/lib/daytime.b +++ b/appl/lib/daytime.b @@ -341,10 +341,26 @@ string2tm(date: string): ref Tm if(!ok) return nil; + # optional time zone + while(date != nil && date[0] == ' ') + date = date[1:]; + if(date != nil && !(date[0] >= '0' && date[0] <= '9')){ + for(i := 0; i < len date; i++) + if(date[i] == ' '){ + (tm.zone, tm.tzoff) = tzinfo(date[0: i]); + date = date[i:]; + break; + } + } + # YY|YYYY - (buf, tm.year) = datenum(date); + (nil, tm.year) = datenum(date); if(tm.year > 1900) tm.year -= 1900; + if(tm.zone == ""){ + tm.zone = "GMT"; + tm.tzoff = 0; + } } else { # Mon was not OK date = odate; @@ -364,10 +380,10 @@ string2tm(date: string): ref Tm (ok, buf) = hhmmss(date, tm); if(!ok) return nil; + (tm.zone, tm.tzoff) = tzinfo(buf); + if(tm.zone == "") + return nil; } - (tm.zone, tm.tzoff) = tzinfo(buf); - if(tm.zone == "") - return nil; return tm; } diff --git a/dis/lib/daytime.dis b/dis/lib/daytime.dis Binary files differindex 0de1b37c..4b8c6daa 100644 --- a/dis/lib/daytime.dis +++ b/dis/lib/daytime.dis diff --git a/man/2/INDEX b/man/2/INDEX index f61422c4..61a1e4d0 100644 --- a/man/2/INDEX +++ b/man/2/INDEX @@ -28,6 +28,7 @@ filet daytime gmt daytime local daytime now daytime +string2tm daytime text daytime time daytime tm2epoch daytime diff --git a/man/2/daytime b/man/2/daytime index 9e284916..01b8a85d 100644 --- a/man/2/daytime +++ b/man/2/daytime @@ -1,6 +1,6 @@ .TH DAYTIME 2 .SH NAME -daytime: text, filet, gmt, local, now, time, tm2epoch \- time conversions +daytime: text, filet, gmt, local, now, string2tm, time, tm2epoch \- time conversions .SH SYNOPSIS .EX include "daytime.m"; @@ -20,13 +20,14 @@ Tm: adt 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; +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 DESCRIPTION These routines perform time conversions relative to the @@ -42,7 +43,7 @@ converts a time structure referenced by .I tm from local or GMT time to a string in the format: .IP -.BR "Sat Jan 1 13:00:00 GMT 2000" . +.B "Sat Jan 1 13:00:00 GMT 2000" .PP .B Filet converts the file access or modification time @@ -70,12 +71,10 @@ converts seconds since the epoch, received in to a time structure in local time. .PP .B Now -returns the time in seconds since the epoch, which -it obtains by reading +returns the time in seconds since the epoch, obtained by reading .B /dev/time (see -.IR cons (3)) -to get the time in microseconds since the epoch. +.IR cons (3)). .PP .B Time converts seconds since the epoch @@ -86,6 +85,26 @@ to the local time as a string in the format converts a time structure referenced by .I tm from local or GMT time to seconds since the epoch. +.PP +.B String2tm +returns a reference to a +.B Tm +value corresponding to the date and time in textual form in string +.IR s , +which must have one of the forms below: +.IP +.EX +Sun, 06 Nov 1994 08:49:37 GMT \fR(RFC822, RFC1123)\fP +Sunday, 06-Nov-94 08:49:37 GMT \fR(RFC850)\fP +Sun Nov 6 08:49:37 GMT 1994 \fR(output of \fPtext\fR, above)\fP +.EE +.PP +A missing time zone in any format is assumed to be +.BR GMT . +.B String2tm +returns nil if +.I s +is not correctly formed. .SH SOURCE .B /appl/lib/daytime.b .SH SEE ALSO |
