From owner-cvs-all@FreeBSD.ORG Tue Aug 24 00:15:38 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3146316A4CE; Tue, 24 Aug 2004 00:15:38 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 25E6443D1D; Tue, 24 Aug 2004 00:15:38 +0000 (GMT) (envelope-from peter@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i7O0FcpN099247; Tue, 24 Aug 2004 00:15:38 GMT (envelope-from peter@repoman.freebsd.org) Received: (from peter@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i7O0Fc94099246; Tue, 24 Aug 2004 00:15:38 GMT (envelope-from peter) Message-Id: <200408240015.i7O0Fc94099246@repoman.freebsd.org> From: Peter Wemm Date: Tue, 24 Aug 2004 00:15:38 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libc/stdtime localtime.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 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, 24 Aug 2004 00:15:38 -0000 peter 2004-08-24 00:15:37 UTC FreeBSD src repository Modified files: lib/libc/stdtime localtime.c Log: struct tm.tm_year is listed as 'years since 1900', and is signed. On 64 bit systems, years roughly -2^31 through 2^31 can be represented in time_t without any trouble. 32 bit time_t systems only range from roughly 1902 through 2038. As a consequence, none of the date munging code for all the various calendar tweaks before then is present. There are other problems including the fact that there was no 'year zero' and so on. So rather than get excited about trying to figure out when the calendar jumped by two weeks etc, simply disallow negative (ie: prior to 1900) years. This happens to have an important side effect. If you bzero a 'struct tm', it corresponds to 'Jan 0, 1900, 00:00 GMT'. This happens to be representable (after canonification) in 64 bit time_t space. Zero tm structs are generally an error and mktime normally returns -1 for them. Interestingly, it tries to canonify the 'jan 0' to 'dec 31, 1899', ie: year -1. This conveniently trips the negative year test above, which means we can trivially detect the null 'tm' struct. This actually tripped up code at work. :-/ (Don't ask) Revision Changes Path 1.40 +3 -0 src/lib/libc/stdtime/localtime.c