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

next in thread | previous in thread | raw e-mail | index | archive | help
Mike Meyer wrote:
> 
> Crist Clark <crist.clark@globalstar.com> types:
> > > > This is a bug, right?
> > >
> > > I don't think it is a bug. The date/time you give to date(1) is
> > > interpreted as being in your local timezone.
> > > What your second example shows is that 2001-04-01 00:00 PDT is the same
> > > time as 2001-03-31 23:00 PST which I believe is correct.
> >
> > I guess an interesting  question is, is there really such a thing as
> > 2001-04-01 00:00 PDT? (Although there is definately a 2001-04-02 01:00 PST.)
> 
> Yes, there is such a time. I'm not sure if there's any place in the
> world that is 1) in the Pacific time zone and 2) isn't on DST at that
> time, but the time exists nonetheless. If you were on Mountain Time,
> I'd point at Arizona.

No, otherway around, does daylight time "exist" when everone I know about
is on standard time. Is there a 2001-04-01 00:00 PDT? But it's not really
important anyway.

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

> 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?

  $ touch -t 200104010000 file_in_pst
  $ touch -t 200104020000 file_in_pdt
  $ ls -l file_in_p?t
  -rw-r--r--  1 cclark  mis  0 Apr  2 00:00 file_in_pdt
  -rw-r--r--  1 cclark  mis  0 Apr  1 00:00 file_in_pst
  $ date -j 200104010000
  Sat Mar 31 23:00:00 PST 2001
  $ date -j 200104020000
  Mon Apr  2 00:00:00 PDT 2001

Yeah, this is a date(1) bug. My timezone is PST8PDT. I should be able
to cross the boundary willy-nilly I want and have the local time 
interpreted _as the local time._
-- 
Crist J. Clark                                Network Security Engineer
crist.clark@globalstar.com                    Globalstar, L.P.
(408) 933-4387                                FAX: (408) 933-4926

The information contained in this e-mail message is confidential,
intended only for the use of the individual or entity named above.  If
the reader of this e-mail is not the intended recipient, or the employee
or agent responsible to deliver it to the intended recipient, you are
hereby notified that any review, dissemination, distribution or copying
of this communication is strictly prohibited.  If you have received this
e-mail in error, please contact postmaster@globalstar.com

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?3B02FF0F.1852C68A>