From owner-freebsd-questions@FreeBSD.ORG Tue Oct 14 17:50:43 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE8251065694 for ; Tue, 14 Oct 2008 17:50:43 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA05.westchester.pa.mail.comcast.net (qmta05.westchester.pa.mail.comcast.net [76.96.62.48]) by mx1.freebsd.org (Postfix) with ESMTP id 883F48FC15 for ; Tue, 14 Oct 2008 17:50:43 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from OMTA07.westchester.pa.mail.comcast.net ([76.96.62.59]) by QMTA05.westchester.pa.mail.comcast.net with comcast id SeNo1a00G1GhbT855hqh2W; Tue, 14 Oct 2008 17:50:41 +0000 Received: from koitsu.dyndns.org ([69.181.141.110]) by OMTA07.westchester.pa.mail.comcast.net with comcast id Shqg1a0102P6wsM3ThqhEE; Tue, 14 Oct 2008 17:50:41 +0000 X-Authority-Analysis: v=1.0 c=1 a=S5iuWK_3y7sA:10 a=5rt6Gh4ksEQA:10 a=QycZ5dHgAAAA:8 a=Hb1FYczW7H1HTDHhqSMA:9 a=DNWicZZujsNWur5eyWYgeWx-j0EA:4 a=EoioJ0NPDVgA:10 a=LY0hPdMaydYA:10 Received: by icarus.home.lan (Postfix, from userid 1000) id BEDF2C9419; Tue, 14 Oct 2008 10:50:40 -0700 (PDT) Date: Tue, 14 Oct 2008 10:50:40 -0700 From: Jeremy Chadwick To: "Mark B." Message-ID: <20081014175040.GA55591@icarus.home.lan> References: <59f4cb420810140943r113f1494la477606c004833ca@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59f4cb420810140943r113f1494la477606c004833ca@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-questions@freebsd.org Subject: Re: mktime() output not the same as the date utility X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2008 17:50:43 -0000 On Tue, Oct 14, 2008 at 12:43:54PM -0400, Mark B. wrote: > I can't figure out from the man pages why > mktime() is giving a different result than date -f. > Both strptime and mktime are supposed to use the > local timezone, as does date. > > The output of date is correct; mktime() is an hour later. > > What am I missing here? I'm betting it's due to DST I believe you have to do the math yourself if tm_isdst is non-zero. Otherwise, consider using functions like ctime() and others (which are also POSIX compliant). -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |