Re: '1 year' = '360 days' ???? - Mailing list pgsql-general

From Guy Fraser
Subject Re: '1 year' = '360 days' ????
Date
Msg-id 41802085.8000602@incentre.net
Whole thread Raw
In response to Re: '1 year' = '360 days' ????  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: '1 year' = '360 days' ????  (Gaetano Mendola <mendola@bigfoot.com>)
Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
Tom Lane wrote:

>Doug McNaught <doug@mcnaught.org> writes:
>
>
>>template1=# select '1 year'::interval = '360 days'::interval;
>> ?column?
>>----------
>> t
>>(1 row)
>>
>>
>
>Yeah, if you look at interval_cmp_internal() it's fairly obvious why.
>I think that this definition is probably bogus, and that only intervals
>that match exactly (equal months parts *and* equal seconds parts) should
>be considered "equal".  However the most obvious way to redefine it
>(compare the months, and only if equal compare the seconds) would lead
>to rather nonintuitive behaviors such as "'1 year' > '1000 days'".
>Anybody have any thoughts about a better way to map the multicomponent
>reality into a one-dimensional sorting order?
>
>(Note also that as Bruno was just mentioning, we really ought to have
>months/days/seconds components, not just months/seconds; which makes the
>comparison issue even more interesting.)
>
>            regards, tom lane
>
>
As any of us who have ever researched how to calculate time know;

1) The amount of time in 1 year depends on the year due to
leap years.
2) The amount of time in 1 month depends on the month and year
because a month is an arbitrary number of days.
3) A week is a theological creation always equal to 7 days.

Using the Gregorian Calendar there are 10 missing days between
Oct. 4, 1582 and Oct. 15, 1582 . Leap Years are (((every 4 years)
except when modulo 100) except when modulo 400).

It is therefore not possible to define a Month or Year in Seconds,
without knowing which Day, Month and Year you calculating.

Time constants :

1 Solar Day = 23 hours 56 minutes 4.091 seconds
1 Lunar Month = 27.32158 days
1 Tropical Year = 365.24215 Solar Days

1 Year in Gregorian time is :
365 Days 5 Hours 49 Minutes 12 Seconds

As it is now obvious there is not any simple way to convert
months to seconds since a month is an abstract number of days used
to split four (13 week) seasons three ways plus one day every non
leap year and two days every leap year.

When calculating any usage based on time, it is a good idea to
store usage in days:hours:minutes:seconds because they are static
and stable, if you discount the deceleration of the earth and
corrections in leap seconds for atomic clocks [see
http://tycho.usno.navy.mil/leapsec.html ].

Trivia: In approximately 620 million years a day will be twice as
long as it is today.



--
Guy Fraser
Network Administrator
The Internet Centre
780-450-6787 , 1-888-450-6787

There is a fine line between genius and lunacy, fear not, walk the
line with pride. Not all things will end up as you wanted, but you
will certainly discover things the meek and timid will miss out on.




pgsql-general by date:

Previous
From: Denis Zaitsev
Date:
Subject: Re: interval to seconds conversion. How?
Next
From: Tom Lane
Date:
Subject: Re: interval to seconds conversion. How?