pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #5806: Julian Date routine miscalculates.
2+ messages / 2 participants
[nested] [flat]
* BUG #5806: Julian Date routine miscalculates.
@ 2010-12-29 17:49 Leslie Satenstein <lsatenstein@yahoo.com>
2010-12-29 18:00 ` Re: BUG #5806: Julian Date routine miscalculates. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Leslie Satenstein @ 2010-12-29 17:49 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 5806
Logged by: Leslie Satenstein
Email address: lsatenstein@yahoo.com
PostgreSQL version: 8.4 + 9.0
Operating system: Linux 64bit
Description: Julian Date routine miscalculates.
Details:
I found the Julian date code that is programmed in Postgres, to be accurate
and fast except for one situation. But, I do have one or two questions.
1) Which calendar is being used?
In the Gregorian Calendar, January 1, 0001 is lowest
> positive date. The day before 1/1/0001, according to the Gregorian
calendar is December 31,-0001 in which the year has a value of negative one
--- there is no zero year in the Gregorian Calendar. (zero year is an
error)
I tested and found the algorithm in Postgres to have the day before January
1,0001 calculating as December 31,0000 even though the world calculates the
day before
January 1,0001 as December 31,-0001.
2) Is the algorithm in Postgres correct? I think not, as the calculations
for the difference in days between
January 1, 0001 and December 31,-0001 is not 367 days, but just the value
1.
To convert the code to work with the Gregorian calendar takes two fixes to
two sub-routines. Each fix is two lines of C code. I have tested the PG Date
C language routines with/without my fix, starting with the year around -4713
to several centuries into the future. As long as both versions do not deal
with negative dates both calculate identically.
3) Does PG want to fully follow the Gregorian Calendar
rule? If so,
4) Would you want my one patch with two fixes that would allow calculating
any two dates later in time than -4711.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #5806: Julian Date routine miscalculates.
2010-12-29 17:49 BUG #5806: Julian Date routine miscalculates. Leslie Satenstein <lsatenstein@yahoo.com>
@ 2010-12-29 18:00 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2010-12-29 18:00 UTC (permalink / raw)
To: Leslie Satenstein <lsatenstein@yahoo.com>; +Cc: pgsql-bugs
"Leslie Satenstein" <lsatenstein@yahoo.com> writes:
> I tested and found the algorithm in Postgres to have the day before January
> 1,0001 calculating as December 31,0000 even though the world calculates the
> day before
> January 1,0001 as December 31,-0001.
As I already replied on the other list, this is not the case:
regression=# select '0001-01-01'::date - 1;
?column?
---------------
0001-12-31 BC
(1 row)
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-12-29 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-12-29 17:49 BUG #5806: Julian Date routine miscalculates. Leslie Satenstein <lsatenstein@yahoo.com>
2010-12-29 18:00 ` Tom Lane <tgl@sss.pgh.pa.us>
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