From owner-freebsd-stable@FreeBSD.ORG Thu Feb 7 17:00:24 2008 Return-Path: Delivered-To: stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E9C216A417 for ; Thu, 7 Feb 2008 17:00:24 +0000 (UTC) (envelope-from rermilov@team.vega.ru) Received: from mail.vega.ru (infra.dev.vega.ru [90.156.167.14]) by mx1.freebsd.org (Postfix) with ESMTP id 1BDAC13C44B for ; Thu, 7 Feb 2008 17:00:23 +0000 (UTC) (envelope-from rermilov@team.vega.ru) Received: from [87.242.97.68] (port=63770 helo=edoofus.dev.vega.ru) by mail.vega.ru with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68 (FreeBSD)) (envelope-from ) id 1JN9O1-0005Mu-Cp; Thu, 07 Feb 2008 16:14:05 +0000 Received: from edoofus.dev.vega.ru (localhost [127.0.0.1]) by edoofus.dev.vega.ru (8.14.2/8.14.2) with ESMTP id m17GE2YW066069; Thu, 7 Feb 2008 19:14:02 +0300 (MSK) (envelope-from rermilov@team.vega.ru) Received: (from ru@localhost) by edoofus.dev.vega.ru (8.14.2/8.14.2/Submit) id m17GDv87066050; Thu, 7 Feb 2008 19:13:57 +0300 (MSK) (envelope-from rermilov@team.vega.ru) X-Authentication-Warning: edoofus.dev.vega.ru: ru set sender to rermilov@team.vega.ru using -f Date: Thu, 7 Feb 2008 19:13:57 +0300 From: Ruslan Ermilov To: Miguel Lopes Santos Ramos Message-ID: <20080207161357.GA65774@team.vega.ru> References: <20071028211538.GA92424@intserv.int1.b.intern> <200710290119.l9T1Jpvs009149@satan.anjos.strangled.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200710290119.l9T1Jpvs009149@satan.anjos.strangled.net> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: hk@alogis.com, stable@FreeBSD.org, eugen@kuzbass.ru Subject: Re: date manupulation strangeness X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Feb 2008 17:00:24 -0000 On Mon, Oct 29, 2007 at 01:19:51AM +0000, Miguel Lopes Santos Ramos wrote: > > From: Holger Kipp > > > > On Mon, Oct 29, 2007 at 01:35:08AM +0700, Eugene Grosbein wrote: > > > On Sun, Oct 28, 2007 at 07:20:11PM +0100, Holger Kipp wrote: > > > > > > > > # unixtime=1193511599 > > > > > # LC_ALL=C TZ=Asia/Krasnoyarsk date -jr $unixtime > > > > > Sun Oct 28 02:59:59 KRAT 2007 > > > > > > Here it shows 'Sun Oct 28 02:59:59 KRAST 2007' really > > > (cut-n-paste error, mea culpa). Take a note of zone name, > > > KRAST stands for 'KRAsnoyarsk Summer Time' and > > > KRAT stands for 'KRAsnoyarsk Time' (winter one). > > > > ah, I see. I can reproduce it here as well: > > > > %setenv LC_ALL C > > %setenv TZ Asia/Krasnoyarsk > > %setenv unixtime 1193511599 > > > > %date -jr $unixtime > > Sun Oct 28 02:59:59 KRAST 2007 > > %date -jf $s $unixtime > > Sun Oct 28 02:59:59 KRAT 2007 > > %date -juf %s $unixtime > > Sat Oct 27 18:59:59 UTC 2007 > > %date -jur $unixtime > > Sat Oct 27 18:59:59 UTC 2007 > > This is a lot of fun! Bugs like this go unnoticed for years... > It is also very exciting finding people at GMT+8. Mind you, we programmers who live at > GMT+0 do a lot of timezone errors because we look at a time and often don't know > whether it's localtime or gmt. At least I do. Then we only find out when we > change to summer time. > > The problem is of course in src/bin/date.c, line 268. Someone added the > following on revision 1.32.2.4: > 267: /* Let mktime() decide whether summer time is in effect. */ > 268: lt->tm_isdst = -1; > > Now, who's mktime() to know? > This line is erasing the output of strptime(), and strptime() knows better than > anyone what the user might have wanted! > [...] > There's no point in naming the revision... the problematic line was introduced > 6 years and 5 months ago by ru... Complete reference: src/bin/date.c Revision 1.32.2.4 > > Is ru around? > > Who fills in a pr for this? > > In summary, I think we should move line 268 to line 191 and erase the comment > on line 267 (mktime() is no one to decide, strptime() must have the final word). > I've committed a different fix, so that it doesn't re-introduce the bug fixed in rev. 1.36 (or 1.32.2.4, which was an MFC of 1.36). Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer