Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 May 2001 17:58:53 -0500
From:      Mike Meyer <mwm@mired.org>
To:        "Crist Clark" <crist.clark@globalstar.com>
Cc:        questions@freebsd.org
Subject:   Re: mktime(3) Bug?
Message-ID:  <15107.1581.994477.796873@guru.mired.org>
In-Reply-To: <3B02FF0F.1852C68A@globalstar.com>
References:  <15106.58596.922075.276361@guru.mired.org> <3B02FF0F.1852C68A@globalstar.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Crist Clark <crist.clark@globalstar.com> 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.

	<mike
--
Mike Meyer <mwm@mired.org>			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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15107.1581.994477.796873>