chapman@eris.berkeley.edu (Brent Chapman) (02/25/88)
MH 6.5, as distributed, incorrectly parses times like "12:?? am" and
"12:?? pm". The problem is, the parser assumes that if a time has a
string "am" in it, the hour should be taken as-is, and that if a time
has a string "pm" in it, 12 should be added to the hour. This gives
incorrect results for times between midnight and 1AM and between noon
and 1PM; the parser translates "12:23 am" into "1223" (in a 24-hour
representation) and "12:23 pm" into "2423" (obviously bogus).
Appended is a patch to zotnet/tws/dtimep.lex to fix this problem.
Hopefully helpfully,
-Brent
--
Brent Chapman Capital Market Technology, Inc.
Senior Programmer/Analyst 1995 University Ave., Suite 390
{lll-tis,ucbvax!cogsci}!capmkt!brent Berkeley, CA 94704
capmkt!brent@{lll-tis.arpa,cogsci.berkeley.edu} Phone: 415/540-6400
======== Patch follows ========
*** ./zotnet/tws/dtimep.lex.orig Wed Feb 24 15:37:02 1988
--- ./zotnet/tws/dtimep.lex Wed Feb 24 15:37:56 1988
***************
*** 187,197 ****
--- 187,203 ----
{D}:{D}{w} |
{D}:{D}{w}am{w} {
tw.tw_hour = CVT2; cp++;
+ /* "12:xx am" == 00xx on 24-hr clock */
+ if (tw.tw_hour == 12)
+ tw.tw_hour = 0;
tw.tw_min = CVT2;
BEGIN Z;
}
{D}:{D}{w}pm{w} {
tw.tw_hour = CVT2 + 12; cp++;
+ /* "12:xx pm" == 12xx on 24-hr clock */
+ if (tw.tw_hour == 24)
+ tw.tw_hour = 12;
tw.tw_min = CVT2;
BEGIN Z;
}leres@cory.Berkeley.EDU (Craig Leres) (02/26/88)
There are definiately bugs in parsetime(); unfortunately, Brent's change breaks the parsing of military time. Appended are the changes I recommend people make to zotnet/tws/dtimep.lex. Also included is a gratuitous spelling fix. Craig ------ *** ./zotnet/tws/dtimep.lex.orig Thu Feb 25 18:23:21 1988 --- ./zotnet/tws/dtimep.lex Wed Feb 24 13:41:21 1988 *************** *** 20,26 **** may (may) jun (jun(e)?) jul (jul(y)?) ! aug (aug(est)?) sep (sep(tember)?) oct (oct(ober)?) nov (nov(ember)?) --- 20,26 ---- may (may) jun (jun(e)?) jul (jul(y)?) ! aug (aug(ust)?) sep (sep(tember)?) oct (oct(ober)?) nov (nov(ember)?) *************** *** 175,188 **** tw.tw_sec = CVT2; BEGIN Z; } ! {D}:{D}{w} | {D}:{D}{w}am{w} { tw.tw_hour = CVT2; cp++; tw.tw_min = CVT2; BEGIN Z; } {D}:{D}{w}pm{w} { ! tw.tw_hour = CVT2 + 12; cp++; tw.tw_min = CVT2; BEGIN Z; } --- 175,196 ---- tw.tw_sec = CVT2; BEGIN Z; } ! {D}:{D}{w} { ! tw.tw_hour = CVT2; cp++; ! tw.tw_min = CVT2; ! BEGIN Z; ! } {D}:{D}{w}am{w} { tw.tw_hour = CVT2; cp++; + if (tw.tw_hour == 12) + tw.tw_hour = 0; tw.tw_min = CVT2; BEGIN Z; } {D}:{D}{w}pm{w} { ! tw.tw_hour = CVT2; cp++; ! if (tw.tw_hour != 12) ! tw.tw_hour += 12; tw.tw_min = CVT2; BEGIN Z; }