Date: Tue, 14 Oct 2008 10:50:40 -0700 From: Jeremy Chadwick <koitsu@FreeBSD.org> To: "Mark B." <mkbucc@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: mktime() output not the same as the date utility Message-ID: <20081014175040.GA55591@icarus.home.lan> In-Reply-To: <59f4cb420810140943r113f1494la477606c004833ca@mail.gmail.com> References: <59f4cb420810140943r113f1494la477606c004833ca@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 |
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081014175040.GA55591>