NetBSD Problem Report #47916

From yamt@NetBSD.org  Tue Jun 11 05:19:40 2013
Return-Path: <yamt@NetBSD.org>
Received: by mollari.NetBSD.org (Postfix, from userid 1270)
	id 9A041705D0; Tue, 11 Jun 2013 05:19:40 +0000 (UTC)
Message-Id: <20130611051940.9A041705D0@mollari.NetBSD.org>
Date: Tue, 11 Jun 2013 05:19:40 +0000 (UTC)
From: yamt@NetBSD.org
Reply-To: yamt@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: parsedate timezone breakage
X-Send-Pr-Version: 3.95

>Number:         47916
>Category:       lib
>Synopsis:       parsedate timezone breakage
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 11 05:20:00 +0000 2013
>Closed-Date:    Sun Apr 19 04:00:16 +0000 2015
>Last-Modified:  Sun Apr 19 04:00:16 +0000 2015
>Originator:     YAMAMOTO Takashi
>Release:        NetBSD current
>Organization:

>Environment:


>Description:
	parsedate timezone handling seems broken.

	i except the following examples print 12:00 regardless of timezones.
		% TZ=EST date -d 12:0
		Tue Jun 11 06:55:00 EST 2013
		% TZ=Japan date -d 12:0
		Tue Jun 11 21:09:00 JST 2013
		% 
>How-To-Repeat:
>Fix:
	revert parsedate.y rev.1.11 and rev.1.13.

>Release-Note:

>Audit-Trail:
From: "YAMAMOTO Takashi" <yamt@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: src/lib/libutil
Date: Wed, 12 Jun 2013 01:46:08 +0000

 Module Name:	src
 Committed By:	yamt
 Date:		Wed Jun 12 01:46:07 UTC 2013

 Modified Files:
 	src/lib/libutil: parsedate.y

 Log Message:
 fix timezone bugs in rev.1.11 and rev.1.13.  PR/47916.


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 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: Matthias Scheler <tron@zhadum.org.uk>
To: gnats-bugs@NetBSD.org
Cc: Alan Barrett <apb@netbsd.org>
Subject: Re: PR/47916 CVS commit: src/lib/libutil
Date: Tue, 9 Jul 2013 13:24:29 +0100

 On Wed, Jun 12, 2013 at 01:50:01AM +0000, YAMAMOTO Takashi wrote:
 > The following reply was made to PR lib/47916; it has been noted by GNATS.
 > 
 > From: "YAMAMOTO Takashi" <yamt@netbsd.org>
 > To: gnats-bugs@gnats.NetBSD.org
 > Cc: 
 > Subject: PR/47916 CVS commit: src/lib/libutil
 > Date: Wed, 12 Jun 2013 01:46:08 +0000
 > 
 >  Module Name:	src
 >  Committed By:	yamt
 >  Date:		Wed Jun 12 01:46:07 UTC 2013
 >  
 >  Modified Files:
 >  	src/lib/libutil: parsedate.y
 >  
 >  Log Message:
 >  fix timezone bugs in rev.1.11 and rev.1.13.  PR/47916.
 >  
 >  
 >  To generate a diff of this commit:
 >  cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/parsedate.y

 This fix is unfortunately not sufficient:

 tron@colwyn:~>date
 Tue Jul  9 13:21:53 BST 2013
 tron@colwyn:~>date -d 14:00
 Tue Jul  9 15:00:00 BST 2013

 The second command should output "14:00:00".

 	Kind regards

 -- 
 Matthias Scheler                                  http://zhadum.org.uk/

From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: src/tests/lib/libutil
Date: Wed, 8 Oct 2014 13:26:47 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Wed Oct  8 13:26:47 UTC 2014

 Modified Files:
 	src/tests/lib/libutil: t_parsedate.c

 Log Message:
 Add tests for PR lib/47916.  Some of these fail.


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 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: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: src/lib/libutil
Date: Wed, 8 Oct 2014 17:38:28 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Wed Oct  8 17:38:28 UTC 2014

 Modified Files:
 	src/lib/libutil: parsedate.y

 Log Message:
 Improved handling of local times.

 * A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
   Timezone to Convert(), instructing it to use mktime() to work
   in the local time zone, instead of using mktime_z to work in UTC
   (and then adding the specified timezone offset).
 * Some old code is removed now that there's no need to find the local
   timezone offset.
 * Allow either one or both of the now and zone arguments to
   parsedate() to be NULL, treating them independently.  Previously,
   if either one was NULL, the other was ignored.
 * If the zone argument is specified, then the current date is calculated
   in the specified zone, not in local time.

 Also add some disabled debug code.

 This should fix PR lib/47916.


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.20 src/lib/libutil/parsedate.y

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: apb@NetBSD.org
State-Changed-When: Thu, 09 Oct 2014 07:15:55 +0000
State-Changed-Why:
I think this problem is fixed.  Please check.
(Needs pullup to netbsd-7.)


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: [netbsd-7] src/tests/lib/libutil
Date: Sat, 11 Oct 2014 16:47:00 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Oct 11 16:47:00 UTC 2014

 Modified Files:
 	src/tests/lib/libutil [netbsd-7]: t_parsedate.c

 Log Message:
 Pull up following revision(s) (requested by apb in ticket #135):
 	tests/lib/libutil/t_parsedate.c: revision 1.11
 Add tests for PR lib/47916.  Some of these fail.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.8.3 -r1.7.8.4 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: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: [netbsd-7] src/lib/libutil
Date: Sat, 11 Oct 2014 16:56:21 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Oct 11 16:56:21 UTC 2014

 Modified Files:
 	src/lib/libutil [netbsd-7]: parsedate.y

 Log Message:
 Pull up following revision(s) (requested by apb in ticket #135):
 	lib/libutil/parsedate.y: revision 1.20
 Improved handling of local times.
 * A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
   Timezone to Convert(), instructing it to use mktime() to work
   in the local time zone, instead of using mktime_z to work in UTC
   (and then adding the specified timezone offset).
 * Some old code is removed now that there's no need to find the local
   timezone offset.
 * Allow either one or both of the now and zone arguments to
   parsedate() to be NULL, treating them independently.  Previously,
   if either one was NULL, the other was ignored.
 * If the zone argument is specified, then the current date is calculated
   in the specified zone, not in local time.
 Also add some disabled debug code.
 This should fix PR lib/47916.


 To generate a diff of this commit:
 cvs rdiff -u -r1.16.6.3 -r1.16.6.4 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: Yasushi Oshima <oshima-ya@yagoto-urayama.jp>
To: gnats-bugs@gnats.netbsd.org
Cc: 
Subject: Re: lib/47916
Date: Wed, 15 Apr 2015 00:56:29 +0900 (JST)

 Is this fix necessary to netbsd-6?

 % uname -srm
 NetBSD 6.1.5 amd64
 % env TZ=Japan date -d 12:0
 Wed Apr 15 21:09:00 JST 2015

 Thanks.
 --
 Yasushi Oshima

From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47916 CVS commit: [netbsd-6] src
Date: Fri, 17 Apr 2015 10:24:10 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Fri Apr 17 10:24:09 UTC 2015

 Modified Files:
 	src/lib/libutil [netbsd-6]: parsedate.3 parsedate.y
 	src/tests/lib/libutil [netbsd-6]: t_parsedate.c

 Log Message:
 Pull up following revision(s) (requested by nonaka in ticket #1291):
 	tests/lib/libutil/t_parsedate.c: revision 1.4-1.13
 	lib/libutil/parsedate.y: revision 1.14-1.20
 	lib/libutil/parsedate.3: revision 1.11-1.14
 Distinguish between a non-error result of (time_t)-1 and an error result.
 Modernise the test code inside #ifdef TEST.
 add rcsid
 fix timezone bugs in rev.1.11 and rev.1.13.  PR/47916.
 Some years don't need the "maybe add 1900 or 2000" adjustment
 that was designed for handling two-digit abbreviated years.
 For example, "1/2/70" still refers to the year 1970, as before,
 but "70-01-02" now refers to the year 70.
 * Add a new yyHaveFullYear member to struct dateinfo, to record whether
   or not the year needs to be adjusted.
 * Code that parses years sets yyHaveFullYear=1 if they know that the
   year should not be adjusted (as is the case for ISO 8601 dates), or if
   they perform their own adjustment (as is the case for CVS timestamps).
 * Move the year adjustment code into a new function, AdjustYear,
   instead of inline in Convert().
 * Make Convert() assume the year doesn't need to be adjusted,
   and make Convert's callers first call AdjustYear() if appropriate.
 A time like HH:MM:SS.sss says nothing about whether DST is on or off.
 Add a new non-terminal "time_numericzone" for a time with
 a numeric timezone.  Move some productions from "time" to "time_numericzone".
 Increment yyHaveZone when encountering one of these.
 Previously, input of the form "HH:MM:SS +ZZZZ" would not have set the
 yyhaveZone flag.
 Improved handling of local times.
 * A magic value USE_LOCAL_TIME (defined as 99999) may be passed as the
   Timezone to Convert(), instructing it to use mktime() to work
   in the local time zone, instead of using mktime_z to work in UTC
   (and then adding the specified timezone offset).
 * Some old code is removed now that there's no need to find the local
   timezone offset.
 * Allow either one or both of the now and zone arguments to
   parsedate() to be NULL, treating them independently.  Previously,
   if either one was NULL, the other was ignored.
 * If the zone argument is specified, then the current date is calculated
   in the specified zone, not in local time.
 Also add some disabled debug code.
 This should fix PR lib/47916.
 Fix capitalization and typo, from Bug Hunting.
 Document that errno may be used to distinguish between a
 non-error result of -1 and an error.
 Document that years in ISO 8601 dates are taken literally.
 "69-09-10" is in the year 69, not 2069.
 The tzoff argument is in minutes (behind/west of UTC), not seconds.
 While here, also say that time = NULL and tzoff = NULL are independent.
 The code doesn't yet implement that, but it will soon.
 mention the PR# in the description like everyone else.
 To be on the safe side, use the category/number notation when referring to
 PRs (otherwise third-party sed-scripts might miss the references). Also
 remove white-space.
 * Test that parsedate("@0", ...) returns (time_t)0 regardless of timezone.
 * Test that parsedate("@-1", NULL, NULL) returns (time_t)-1
   without setting errno.
 Test parsedate("@-2",...) (should return -2 and not set errno);
 and parsedate("@junk",...) (should return -1 and set errno).
 We were already testing "@-1".
 Add local parsecheck() function and use it for several tests.
 Instead of just checking that parsedate(3) does not return an error,
 also pass the result through localtime_r(3) or gmtime_r(3) and check the
 year/month/day/hour/minute/second fields in the resulting struct tm.
 Add comments for some non-obvious cases.
 Also add a test with year=70, which is documented to be treated as 1970.
 Adapt to a recent change in parsedate().
 "9/10/69" still refers to 2069, and "9/10/70" still refers to 1970,
 but "69-09-10" and "70-09-10" now refer to the years 69 and 70.
 Add tests for PR lib/47916.  Some of these fail.
 When tests fail, print all args, notjust the date string.
 2013-07-09 was in British Summer TIme, so use tzoff=-60, not 0.


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.10.8.1 src/lib/libutil/parsedate.3
 cvs rdiff -u -r1.11.2.1 -r1.11.2.2 src/lib/libutil/parsedate.y
 cvs rdiff -u -r1.3 -r1.3.2.1 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: feedback->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Sun, 19 Apr 2015 04:00:16 +0000
State-Changed-Why:
pulled up.
Thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.