Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xm556-0004ny-No for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Nov 2014 18:13:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xm555-0006kk-U8 for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Nov 2014 18:13:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xm555-0006ke-BE for pgsql-bugs@postgresql.org; Wed, 05 Nov 2014 18:13:19 +0000 Received: from smtp-out2.gransy.com ([77.78.126.49]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xm551-00065N-ED for pgsql-bugs@postgresql.org; Wed, 05 Nov 2014 18:13:18 +0000 Received: from smtp-out.gransy.com (localhost [127.0.0.1]) by smtp-out2.gransy.com (Postfix) with ESMTP id 366723F017C for ; Wed, 5 Nov 2014 19:13:17 +0100 (CET) Received: from smtp.gransy.com (smtp.simplia.cz [77.78.126.20]) by smtp-out2.gransy.com (Postfix) with ESMTP id BDA223F0153 for ; Wed, 5 Nov 2014 19:13:16 +0100 (CET) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz [78.45.139.138]) (Authenticated sender: tv@fuzzy.cz) by smtp.gransy.com (Postfix) with ESMTPSA id 1CE2A19A03CD for ; Wed, 5 Nov 2014 19:13:09 +0100 (CET) Message-ID: <545A68B8.8000803@fuzzy.cz> Date: Wed, 05 Nov 2014 19:13:12 +0100 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: BUG #11883: Year 1500 not treated as leap year when it was a leap year References: <20141105175607.26929.23188@wrigleys.postgresql.org> <20141105180225.GB10345@momjian.us> In-Reply-To: <20141105180225.GB10345@momjian.us> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 5.11.2014 19:02, Bruce Momjian wrote: > On Wed, Nov 5, 2014 at 05:56:07PM +0000, hunsakerbn@familysearch.org wrote: >> The following bug has been logged on the website: >> >> Bug reference: 11883 >> Logged by: Bruce Hunsaker >> Email address: hunsakerbn@familysearch.org >> PostgreSQL version: 9.3.5 >> Operating system: Linux >> Description: >> >> Entering historical dates we found we could not enter a date of '1500-02-29' >> Even though 1500 is documented to be a leap year. Tested with date and >> timestamp column types. >> >> To reproduce: >> psql> create table date_test (mydate date); >> CREATE TABLE >> psql> insert into date_test values ('1500-02-29'); >> ERROR: date/time field value out of range: "1500-02-29" >> LINE 1: insert into date_test values ('1500-02-29'); >> >> psql> insert into date_test values ('1500-02-28'); >> INSERT 0 1; >> >> So, Feb 29, is not allowed but Feb 28 is. > > Uh, what makes you think 1500 was a leap year? This is the canonical > way to calculate which years are leap years: > > #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) > > Because 1500 % 100 == 0, I think 1500 was not a leap year. Well, the thing is this only works since 1582. Prior to that, only the first condition was used. Tomas -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs