Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 May 2001 17:43:04 -0700
From:      "Crist Clark" <crist.clark@globalstar.com>
To:        freebsd-questions@freebsd.org
Subject:   mktime(3) Bug?
Message-ID:  <3B01CD18.6E725786@globalstar.com>

next in thread | raw e-mail | index | archive | help
Before I send in a PR, I wanted to make sure this was really a bug and
not some bizarre "feature" everyone already knew about but me.

I noticed odd behavior when doing some conversions with date(1) (FreeBSD's
date(1) rewls for letting you do these kinds of conversions, BTW). Note what
happens when I cross a daylight savings time boundary (which was the 1st 
of April for my timezone this year),

  $ date
  Tue May 15 17:11:52 PDT 2001
  $ date -j -f %Y%m%d%H%M 200104020000
  Mon Apr  2 00:00:41 PDT 2001
  $ date -j -f %Y%m%d%H%M 200104010000
  Sat Mar 31 23:00:46 PST 2001
  
At first I thought it might be a conversion-only problem, but you get 
the same thing if you _set_ the time across a DST boundary. Looking at
the date(1) code and reviewing the manpages, my best guess is that
mktime(3) uses the _current_ DST settings when setting the "target" 
time.

That would explain the behavior. And that, IMHO, is a bug. When a
user types that second command, he expects to see midnight on the
1st, not 11 PM on the 31st. The DST of the "target" time should be
used by mktime(3), not the current one. This is especially true if 
the user were setting the time rather than just displaying it.

This is a bug, right?
-- 
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?3B01CD18.6E725786>