Subject: bin/1743: at(1) gets am/pm reversed when hour is 12
To: None <gnats-bugs@gnats.netbsd.org>
From: None <Mark_Weaver@brown.edu>
List: netbsd-bugs
Date: 11/08/1995 18:30:32
>Number: 1743
>Category: bin
>Synopsis: at(1) gets am/pm reversed when hour is 12
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: mhw
>Arrival-Date: Wed Nov 8 21:05:00 1995
>Last-Modified:
>Originator: Mark Weaver
>Organization:
Brown University Department of Computer Science
>Release: NetBSD-current 11/6/95
>Environment:
NetBSD peace.netspace.org 1.1_ALPHA NetBSD 1.1_ALPHA (WEAVER) #0: Wed Nov 1 16:34:36 EST 1995 mhw@peace.netspace.org:/usr/src/sys/arch/i386/compile/WEAVER i386
>Description:
at(1) get am and pm reversed when the hour is 12. `at 12am` will go
at noon and `at 12pm` at midnight.
>How-To-Repeat:
at 12am
atq
at 12pm
atq
>Fix:
diff -c src/usr.bin/at/parsetime.c.mhw1 src/usr.bin/at/parsetime.c
*** src/usr.bin/at/parsetime.c.mhw1 Fri Oct 13 23:01:11 1995
--- src/usr.bin/at/parsetime.c Wed Nov 8 02:12:52 1995
***************
*** 349,370 ****
if (token() == DOT) {
expect(NUMBER);
minute = atoi(sc_token);
- if (minute > 59)
- panic("garbled time");
token();
} else if (tlen == 4) {
minute = hour%100;
- if (minute > 59)
- panic("garbeld time");
hour = hour/100;
}
/*
* check if an AM or PM specifier was given
*/
if (sc_tokid == AM || sc_tokid == PM) {
if (hour > 12)
panic("garbled time");
if (sc_tokid == PM)
hour += 12;
--- 349,371 ----
if (token() == DOT) {
expect(NUMBER);
minute = atoi(sc_token);
token();
} else if (tlen == 4) {
minute = hour%100;
hour = hour/100;
}
+ if (minute > 59)
+ panic("garbled time");
+
/*
* check if an AM or PM specifier was given
*/
if (sc_tokid == AM || sc_tokid == PM) {
if (hour > 12)
panic("garbled time");
+ else if (hour == 12)
+ hour = 0;
if (sc_tokid == PM)
hour += 12;
***************
*** 382,391 ****
tm->tm_hour = hour;
tm->tm_min = minute;
- if (tm->tm_hour == 24) {
- tm->tm_hour = 0;
- tm->tm_mday++;
- }
} /* tod */
--- 383,388 ----
>Audit-Trail:
>Unformatted: