From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: hunsakerbn@familysearch.org
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #11883: Year 1500 not treated as leap year when it was a leap year
Date: Thu, 6 Nov 2014 02:34:51 -0500
Message-ID: <20141106073451.GA4253@momjian.us> (raw)
In-Reply-To: <15535.1415211201@sss.pgh.pa.us>
References: <20141105175607.26929.23188@wrigleys.postgresql.org>
<20141105180225.GB10345@momjian.us>
<CABUevEzP=g=O=Nmg+DMjwCL+74WsnPdTb98vbs6sSbQq_kdASw@mail.gmail.com>
<15535.1415211201@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Wed, Nov 5, 2014 at 01:13:21PM -0500, Tom Lane wrote:
> Magnus Hagander <magnus@hagander.net> writes:
> > On Wed, Nov 5, 2014 at 7:02 PM, Bruce Momjian <bruce@momjian.us> wrote:
> >> Because 1500 % 100 == 0, I think 1500 was not a leap year.
>
> > I believe it was a leap year in the Julian calendar, maybe that's
> > where the difference comes from?
>
> Indeed. We won't be changing our code though, because we document that
> we follow Gregorian calendar rules even before that calendar was instituted
> (ie, proleptic Gregorian calendar). You could argue for doing that
> differently, but then what are you going to do for dates before the Julian
> calendar was instituted? In any case, this behavior appears to be
> required by the SQL standard, which repeatedly says that datetime values
> are "constrained according to the Gregorian calendar".
I have applied the attached C comment to document why we use the
Gregorian calendar for pre-1582 years.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:leap.diff (text/x-diff, 687B) downloaddiff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.hnew file mode 100644index 9b53ee3..548758a
*** a/src/include/utils/datetime.h
--- b/src/include/utils/datetime.h
*************** extern const char *const months[]; /* m
*** 271,276 ****
--- 271,281 ----
extern const char *const days[]; /* days (full names) */
extern const int day_tab[2][13];
+ /*+ * These are the rules for the Gregorian calendar, which was adopted in 1582.+ * However, we use this calculation for all prior years as well because the+ * SQL standard specifies use of the Gregorian calendar.+ */
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, magnus@hagander.net, hunsakerbn@familysearch.org
Subject: Re: BUG #11883: Year 1500 not treated as leap year when it was a leap year
In-Reply-To: <20141106073451.GA4253@momjian.us>
References: <20141105175607.26929.23188@wrigleys.postgresql.org> <20141105180225.GB10345@momjian.us> <CABUevEzP=g=O=Nmg+DMjwCL+74WsnPdTb98vbs6sSbQq_kdASw@mail.gmail.com> <15535.1415211201@sss.pgh.pa.us> <20141106073451.GA4253@momjian.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox