From 9b2ea11c98d609db38eeb3f86e08ab2e54baa9ed Mon Sep 17 00:00:00 2001 From: John Polstra Date: Fri, 19 Jul 1996 00:44:55 +0000 Subject: Fix botches in the handling of "AM" and "PM": 12:xx PM is 12:xx, not 24:xx. 12:xx AM is 00:xx, not 12:xx. --- usr.bin/at/parsetime.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usr.bin/at') diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c index a54e7f0aed44..50c7137803d8 100644 --- a/usr.bin/at/parsetime.c +++ b/usr.bin/at/parsetime.c @@ -130,7 +130,7 @@ static size_t sc_len; /* scanner - lenght of token buffer */ static int sc_tokid; /* scanner - token id */ static int sc_tokplur; /* scanner - is token plural? */ -static char rcsid[] = "$Id: parsetime.c,v 1.1 1995/05/24 15:07:32 ig25 Exp $"; +static char rcsid[] = "$Id: parsetime.c,v 1.6 1995/08/21 12:32:50 ache Exp $"; /* Local functions */ @@ -367,8 +367,13 @@ tod(struct tm *tm) if (hour > 12) panic("garbled time"); - if (sc_tokid == PM) - hour += 12; + if (sc_tokid == PM) { + if (hour != 12) /* 12:xx PM is 12:xx, not 24:xx */ + hour += 12; + } else { + if (hour == 12) /* 12:xx AM is 00:xx, not 12:xx */ + hour -= 12; + } token(); } else if (hour > 23) -- cgit v1.2.3