From owner-freebsd-questions Wed May 16 15:58:59 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 5D33B37B423 for ; Wed, 16 May 2001 15:58:55 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 90953 invoked by uid 100); 16 May 2001 22:58:54 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15107.1581.994477.796873@guru.mired.org> Date: Wed, 16 May 2001 17:58:53 -0500 To: "Crist Clark" Cc: questions@freebsd.org Subject: Re: mktime(3) Bug? In-Reply-To: <3B02FF0F.1852C68A@globalstar.com> References: <15106.58596.922075.276361@guru.mired.org> <3B02FF0F.1852C68A@globalstar.com> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Crist Clark types: > > > I was playing with some file modification times. When I 'ls -l' a directory, > > > the times on the files for those from before Apr 1 are correct. That is, > > > since they were created during PST, the times are still given as PST. When > > > my current timezone shifts to PDT, files that were made in PST still show > > > the correct PST time. Why would I not expect the same behavior from date(1)? > > > When I give date(1) a time that occurs in PST, why shouldn't it interpret > > > it as a PST time? > > > > Because you're *not* in PST. The time you gave it doesn't have > > timezone information, and hence could be any of over two dozen > > different times. It isn't known to be PST time until *after* you've > > chosen to interpret it as a specific timezone. Once you've done that - > > it's to late to interpret it as a different timezone. That it then > > switches to PST on display is a convenience. You can disable that by > > setting TZ for the current timezone before invoking the date command. > > That's not really how things work. According to the operating system, > my timezone is _always_ PST8PDT. My timezone, as far as the OS is > concerned, never changes when we shift to daylight time. The more I > think about this now, the more wrong the date(1) behavior seems. The kernel doesn't know jack about your timezone, and it shouldn't. The utilities get your *default* timezone from /etc/localtime. You can set it to whatever you like, including things like "PST8" or - if want to be sure of what's going on - "GMT". > > Personally, I think giving date a time sans TZ information should use > > GMT, but I'm a known curmudgeon. If you still feel it's a bug, PR it > > and see if the a committer agrees with you. > Well, how come touch(1) can figure this out but date(1) cannot? Because the author of touch told mktime to figure out whether the time interpreted according to the timezone in use was DST in that timezone, and the author of date simply had it use the current local timezone. Both of them have the interesting problem in that you can specify perfectly legal looking times that they will claim don't exist - which is why I think that they ought to use GMT. > Yeah, this is a date(1) bug. So submit the PR, all ready. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message