Re: [GENERAL] Re: [HACKERS] Gregorian Calendar - Mailing list pgsql-general

From José Soares
Subject Re: [GENERAL] Re: [HACKERS] Gregorian Calendar
Date
Msg-id 3714B6B6.F745D41D@sferacarta.com
Whole thread Raw
In response to Gregorian Calendar  (José Soares <jose@sferacarta.com>)
List pgsql-general
Hi Thomas,

Thomas Lockhart ha scritto:

> > I have a question about dates.
> > The Gregorian reform of calendar skiped 10 days on Oct, 1582.
> > This reform was accepted by Great Britain and Dominions (including
> > what is now the USA) only in 1752.
> > If I insert a date that doesn't exist PostgreSQL accepts it.
> > Should it be considered normal ?
>
> As Peter says, this is tricky.
>
> Date conventions before the 19th century make for interesting reading,
> but are not imho consistant enough to warrant coding into a date/time
> handler.
>
> As you probably have noticed, we use Julian date calculations for our
> date/time support.

I suppose you refer to Julian Day invented by the French scholar
Joseph Justus Scaliger (1540-1609)
that probably takes its name from the Scaliger's father,
the Italian scholar Julius Caesar Scaliger (1484-1558).
Astronomers have used the Julian period to assign a unique number to
every day since 1 January 4713 BC. This is the so-called Julian Day
(JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC
to noon UTC on 2 January 4713 BC.

Julian Day is different from Julian Date

The Julian calendar was introduced by Julius Caesar in 45 BC. It was
in common use until the 1582, when countries started changing to the
Gregorian calendar.

In the Julian calendar, the tropical year is approximated as 365 1/4
days = 365.25 days. This gives an error of 1 day in approximately 128

and this is why  pope Gregory XIII  in accordance with instructions
from the Council of Trent reformed the calendar to correct this error.

In the Gregorian calendar, the tropical year is approximated as
365 + 97 / 400 days = 365.2425 days. Thus it takes approximately 3300
years for the tropical year to shift one day with respect to the
Gregorian calendar.

The approximation 365+97/400 is achieved by having 97 leap years
every 400 years.

The Gregorian calendar has 97 leap years every 400 years:

        Every year divisible by 4 is a leap year.
        However, every year divisible by 100 is not a leap year.
        However, every year divisible by 400 is a leap year after all.

So, 1700, 1800, 1900, 2100, and 2200 are not leap years. But 1600,
2000, and 2400 are leap years.

instead in the Julian calendar only years divisible by 4 are leap years.

The papal bull of February 1582 decreed that 10 days should be dropped
from October 1582 so that 15 October should follow immediately after
4 October.
This was observed in Italy, Poland, Portugal, and Spain. Other Catholic
countries followed shortly after, but Protestant countries were
reluctant to change, and the Greek orthodox countries didn't change
until the start of this century.

The reform was observed by Great Britain and Dominions (including what is
now the USA)
in 1752.
The 2 Sep 1752 was followed by 14 Sep 1752.

This is why unix has the cal 9 1752 like this:
   September 1752
 S  M Tu  W Th  F  S
             1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

My question is:
^^^^^^^^^^^^

If SQL92 says:

         (Second Informal Review Draft) ISO/IEC 9075:1992, Database
         Language SQL- July 30, 1992

5.3 literals
         22)Within the definition of a <datetime literal>, the <datetime
            value>s are constrained by the natural rules for dates and
times
            according to the Gregorian calendar.
                                     ^^^^^^^^^^^^^^^

Dates between 1752-09-03 and 1752-09-13.
Are they valid dates?
^^^^^^^^^^^^^^^^

> They have the nice property of correctly
> predicting/calculating any date more recent than something like 4013BC
> to far into the future, using the assumption that the length of the
> year is 365.25 days. This is a very recently adopted convention
> (sometime in the 1800s I had thought, but perhaps it was during the
> same "reform" in 1752).
>
> I've toyed with the idea of implementing a Chinese dynastic calendar,
> since it seems to be more predictable than historical European
> calendars.

People's Republic of China uses the Gregorian calendar
for civil purposes. Chinese calendar is used for determining
festivals.

The beginnings of the Chinese calendar can be traced back to the 14th
century BC. Legend has it that the Emperor Huangdi invented the
calendar in 2637 B

José



pgsql-general by date:

Previous
From: "Ross J. Reedstrom"
Date:
Subject: Re: [GENERAL] Would this project be of interest to anyone?
Next
From: Karl DeBisschop
Date:
Subject: user-defined aggreaget functions