From owner-cvs-all@FreeBSD.ORG Tue Feb 19 16:32:14 2008 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5387516A41B; Tue, 19 Feb 2008 16:32:14 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id E966B13C47E; Tue, 19 Feb 2008 16:32:13 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m1JGOQfm047169; Tue, 19 Feb 2008 09:24:26 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 19 Feb 2008 09:30:04 -0700 (MST) Message-Id: <20080219.093004.-1749705352.imp@bsdimp.com> To: kientzle@freebsd.org From: "M. Warner Losh" In-Reply-To: <47BA963B.2060704@freebsd.org> References: <200802190602.m1J622Fe079227@repoman.freebsd.org> <20080219071953.GP64299@server.vk2pj.dyndns.org> <47BA963B.2060704@freebsd.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, cvs-all@freebsd.org, cvs-src@freebsd.org Subject: Re: cvs commit: src/lib/libarchive archive_read_support_format_iso9660.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2008 16:32:14 -0000 In message: <47BA963B.2060704@freebsd.org> Tim Kientzle writes: : Peter Jeremy wrote: : > On Tue, Feb 19, 2008 at 06:02:02AM +0000, Tim Kientzle wrote: : > : >> Without that, I : >> don't see a really good alternative to just giving up and converting to : >> localtime with mktime(). : > : > mktime() and timegm() basically use successive approximation (binary : > search) with localtime() and gmtime() - so you can fairly easily : > create your own timegm(). : : I'll probably do this soon. I thought I had some useful : workarounds, but each one has broken down on some system : or another. : : > If you have a normalised date, I have a direct formula to go from : > year/month/day to number of days past some epoch ... : : I have such code as well, but it has some assumptions : that I'm wary of: : * ISO C doesn't require that time_t count seconds : (POSIX does, so this is probably not a real concern : in practice) time_t is defined in 7.23.3.5.2 to be: [#2] The time function determines the current calendar time. The encoding of the value is unspecified. so time_t can be anything, really, and still conform to the ANSI-C standard. It must also be an arithmetic type. But it could return the number of days since Julius Caesar assumed the thrown so long as difftime() returns the number of seconds. POSIX is more demanding here and, despite its many flaws, is better. : * None of the standards defines the epoch (if I remember : correctly, old Mac OS used a different epoch, so this is : not entirely academic). POSIX defines the epoch to be Jan 1, 1970, which effectively defines it for everybody. : I've also considered trying to measure the local system : epoch and then use direct calculation from there, but : that's also really messy to get right. The binary : search seems the most robust approach; I just haven't : had time to research it yet. localtime suffers from too many discontinuities to be 'easy' to compute. Warner