Date: Thu, 7 Feb 2008 19:13:57 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Miguel Lopes Santos Ramos <miguel@anjos.strangled.net> Cc: hk@alogis.com, stable@FreeBSD.org, eugen@kuzbass.ru Subject: Re: date manupulation strangeness Message-ID: <20080207161357.GA65774@team.vega.ru> In-Reply-To: <200710290119.l9T1Jpvs009149@satan.anjos.strangled.net> References: <20071028211538.GA92424@intserv.int1.b.intern> <200710290119.l9T1Jpvs009149@satan.anjos.strangled.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 29, 2007 at 01:19:51AM +0000, Miguel Lopes Santos Ramos wrote: > > From: Holger Kipp <hk@alogis.com> > > > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080207161357.GA65774>