Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!agate!eris.berkeley.edu!chapman From: chapman@eris.berkeley.edu (Brent Chapman) Newsgroups: comp.mail.mh Subject: BUGFIX: times like "12:?? am" and "12:?? pm" parsed incorrectly Message-ID: <7170@agate.BERKELEY.EDU> Date: 25 Feb 88 00:02:15 GMT Sender: usenet@agate.BERKELEY.EDU Reply-To: chapman@eris.berkeley.edu (Brent Chapman) Organization: UNIXversity of California at Berkeley Lines: 43 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; }