History

20070901-1541

Charles.Forsyth committed 19 years ago

Commit de2f8de1 parent b2446075 files · +54 −16Browse files

Unified · Split

5 files
  1. CHANGES +2 −0
  2. appl/lib/daytime.b +20 −4
  3. dis/lib/daytime.dis +0 −0
  4. man/2/INDEX +1 −0
  5. man/2/daytime +32 −13
CHANGES+2−0
@@ -1,3 +1,5 @@
1+20070902
2+ make /appl/lib/daytime.b accept Daytime->text's output; add string2tm to man page (issue 59)
13 20070901
24 add andrey's changes to emu/MacOSX/win.c (used by emu/MacOSX/mkfile-a)
35 add saoret's changes to dis/lookman, dis/man (issue 58)
appl/lib/daytime.b+20−4
@@ -341,10 +341,26 @@ string2tm(date: string): ref Tm · 340 unmodified lines
341341 if(!ok)
342342 return nil;
343343
344+ # optional time zone
345+ while(date != nil && date[0] == ' ')
346+ date = date[1:];
347+ if(date != nil && !(date[0] >= '0' && date[0] <= '9')){
348+ for(i := 0; i < len date; i++)
349+ if(date[i] == ' '){
350+ (tm.zone, tm.tzoff) = tzinfo(date[0: i]);
351+ date = date[i:];
352+ break;
353+ }
354+ }
355+
344356 # YY|YYYY
345− (buf, tm.year) = datenum(date);
357+ (nil, tm.year) = datenum(date);
346358 if(tm.year > 1900)
347359 tm.year -= 1900;
360+ if(tm.zone == ""){
361+ tm.zone = "GMT";
362+ tm.tzoff = 0;
363+ }
348364 } else {
349365 # Mon was not OK
350366 date = odate;
@@ -364,10 +380,10 @@ string2tm(date: string): ref Tm · 13 unmodified lines
364380 (ok, buf) = hhmmss(date, tm);
365381 if(!ok)
366382 return nil;
383+ (tm.zone, tm.tzoff) = tzinfo(buf);
384+ if(tm.zone == "")
385+ return nil;
367386 }
368− (tm.zone, tm.tzoff) = tzinfo(buf);
369− if(tm.zone == "")
370− return nil;
371387
372388 return tm;
373389 }
dis/lib/daytime.dis+0−0

Binary file not shown.

man/2/INDEX+1−0
@@ -28,6 +28,7 @@ filet daytime · 27 unmodified lines
2828 gmt daytime
2929 local daytime
3030 now daytime
31+string2tm daytime
3132 text daytime
3233 time daytime
3334 tm2epoch daytime
man/2/daytime+32−13
@@ -1,6 +1,6 @@
11 .TH DAYTIME 2
22 .SH NAME
3−daytime: text, filet, gmt, local, now, time, tm2epoch \- time conversions
3+daytime: text, filet, gmt, local, now, string2tm, time, tm2epoch \- time conversions
44 .SH SYNOPSIS
55 .EX
66 include "daytime.m";
@@ -20,13 +20,14 @@ Tm: adt · 13 unmodified lines
2020 tzoff: int; # time zone offset (seconds from GMT)
2121 };
2222
23−text: fn(tm: ref Tm): string;
24−filet: fn(now, t: int): string;
25−gmt: fn(tim: int): ref Tm;
26−local: fn(tim: int): ref Tm;
27−now: fn(): int;
28−time: fn(): string;
29−tm2epoch: fn(tm: ref Tm): int;
23+text: fn(tm: ref Tm): string;
24+filet: fn(now, t: int): string;
25+gmt: fn(tim: int): ref Tm;
26+local: fn(tim: int): ref Tm;
27+now: fn(): int;
28+time: fn(): string;
29+tm2epoch: fn(tm: ref Tm): int;
30+string2tm: fn(date: string): ref Tm;
3031 .EE
3132 .SH DESCRIPTION
3233 These routines perform time conversions relative to the
@@ -42,7 +43,7 @@ converts a time structure referenced by · 9 unmodified lines
4243 .I tm
4344 from local or GMT time to a string in the format:
4445 .IP
45−.BR "Sat Jan 1 13:00:00 GMT 2000" .
46+.B "Sat Jan 1 13:00:00 GMT 2000"
4647 .PP
4748 .B Filet
4849 converts the file access or modification time
@@ -70,12 +71,10 @@ converts seconds since the epoch, received in · 21 unmodified lines
7071 to a time structure in local time.
7172 .PP
7273 .B Now
73−returns the time in seconds since the epoch, which
74−it obtains by reading
74+returns the time in seconds since the epoch, obtained by reading
7575 .B /dev/time
7676 (see
77−.IR cons (3))
78−to get the time in microseconds since the epoch.
77+.IR cons (3)).
7978 .PP
8079 .B Time
8180 converts seconds since the epoch
@@ -86,6 +85,26 @@ to the local time as a string in the format · 4 unmodified lines
8685 converts a time structure referenced by
8786 .I tm
8887 from local or GMT time to seconds since the epoch.
88+.PP
89+.B String2tm
90+returns a reference to a
91+.B Tm
92+value corresponding to the date and time in textual form in string
93+.IR s ,
94+which must have one of the forms below:
95+.IP
96+.EX
97+Sun, 06 Nov 1994 08:49:37 GMT \fR(RFC822, RFC1123)\fP
98+Sunday, 06-Nov-94 08:49:37 GMT \fR(RFC850)\fP
99+Sun Nov 6 08:49:37 GMT 1994 \fR(output of \fPtext\fR, above)\fP
100+.EE
101+.PP
102+A missing time zone in any format is assumed to be
103+.BR GMT .
104+.B String2tm
105+returns nil if
106+.I s
107+is not correctly formed.
89108 .SH SOURCE
90109 .B /appl/lib/daytime.b
91110 .SH SEE ALSO