NetBSD Problem Report #52101
From kre@munnari.OZ.AU Tue Mar 21 18:46:48 2017
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 36D6D7A0F3
for <gnats-bugs@www.NetBSD.org>; Tue, 21 Mar 2017 18:46:48 +0000 (UTC)
Message-Id: <201703211846.v2LIkR8a017284@andromeda.noi.kre.to>
Date: Wed, 22 Mar 2017 01:46:27 +0700 (ICT)
From: kre@munnari.OZ.AU
To: gnats-bugs@www.NetBSD.org
Subject: parsedate does not handle 12:30 am or 12:30 pm correctly
X-Send-Pr-Version: 3.95
>Number: 52101
>Category: lib
>Synopsis: parsedate does not handle 12:30 am or 12:30 pm correctly
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 21 18:50:00 +0000 2017
>Closed-Date: Wed Mar 22 01:29:32 +0000 2017
>Last-Modified: Wed Mar 22 01:29:32 +0000 2017
>Originator: Robert Elz
>Release: NetBSD 7.99.65 (all for a long time)
>Organization:
>Environment:
System: NetBSD andromeda.noi.kre.to 7.99.43 NetBSD 7.99.43 (VBOX64-1.2-20161202) #21: Sat Dec 3 00:43:51 ICT 2016 kre@magnolia.noi.kre.to:/usr/obj/current/kernels/amd64/VBOX64 amd64
Architecture: x86_64
Machine: amd64
>Description:
date -d '12:30 am'
Wed Mar 22 12:30:00 ICT 2017
date -d '12:30 pm'
date: Cannot parse `12:30 pm'
On older NetBSD there's less error checking in parsedate(), and
instead of the error, we get ...
date -d '12:30 pm'
Thu Mar 23 00:30:00 ICT 2017
These examples were all run (approximately) at
date
Wed Mar 22 01:36:15 ICT 2017
which is
date -u
Tue Mar 21 18:36:01 UTC 2017
>How-To-Repeat:
Just run the examples above.
The problem is that parsedate() implements 'am' and 'pm"
in an extremely crude way, just:
if pm is speficied, add 12 to the hours value, otherwise,
use the hours unchanged.
That's fine for '1 am' and '1 pm' but causes the results above
when hours == 12.
>Fix:
Coming soon... First, the ATF tests will be extended to
look for this case (and expected to fail). This PR is so
there's a number to go in the "expected to fail" message...
Then parsedate will be fixed - and at the same time support
will be added for "12 noon" and "12 midnight" - it would be
nice if "12 am" and "12 pm" could be made errors (since they
are technically meaningless) but everyone (and their dogs) uses
"12 am" to mean "12 midnight", and "12 pm" to mean "12 noon",
so making them be errors would be counter productive (but
they should produce the intended results, not bogus ones.)
[Aside: I noticed the parsing error that is the subject of the
PR when my testing of code for noon/midnight was failing...]
>Release-Note:
>Audit-Trail:
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52101 CVS commit: src/tests/lib/libutil
Date: Tue, 21 Mar 2017 20:06:28 +0000
Module Name: src
Committed By: kre
Date: Tue Mar 21 20:06:27 UTC 2017
Modified Files:
src/tests/lib/libutil: t_parsedate.c
Log Message:
PR lib/52101
Add 6 extra tests for the 12am/12pm bug - all currently expected to fail.
(That is, 6 subtests of the "times" test will fail, all new ones)>
While here, when parsedate() fails (returns -1) avoid converting that
failure value (-1) to a struct tm (1969-12-31T23:59:59 UTC) and then
comparing the values with those expected by the test, and complaining
about all of those (where ANY was not permitted) that don't match...
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libutil/t_parsedate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52101 CVS commit: src/lib/libutil
Date: Wed, 22 Mar 2017 00:59:06 +0000
Module Name: src
Committed By: kre
Date: Wed Mar 22 00:59:06 UTC 2017
Modified Files:
src/lib/libutil: parsedate.y
Log Message:
Fix PR lib/52101 -- 12:30 am is 00:30:00 and 12:30 pm is 12:30:00
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libutil/parsedate.y
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52101 CVS commit: src/tests/lib/libutil
Date: Wed, 22 Mar 2017 01:00:19 +0000
Module Name: src
Committed By: kre
Date: Wed Mar 22 01:00:19 UTC 2017
Modified Files:
src/tests/lib/libutil: t_parsedate.c
Log Message:
Since PR lib/52101 is now fixed, the tests for its bug should no longer fail.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libutil/t_parsedate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Wed, 22 Mar 2017 01:29:32 +0000
State-Changed-Why:
Problem fixed
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.