forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5db5146
committed
Fix j2day() to behave sanely for negative Julian dates.
Somebody had apparently once figured that casting to unsigned int wouldproduce the right output for negative inputs, but that would only betrue if 2^32 were a multiple of 7, which of course it ain't. We needto use a signed division and then correct the sign of the remainder.AFAICT, the only case where this would arise currently is when doingISO-week calculations for dates in 4714BC, where we'd compute anegative Julian date representing 4714-01-04BC and then do somearithmetic with it. Since we don't even really document support forsuch dates, this is not of much consequence. But we may as wellget it right.Per report from Vitaly Burovoy.1 parenta70e13a commit5db5146
1 file changed
+6
-7
lines changedLines changed: 6 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
358 |
| - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
359 | 363 |
| |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 |
| - | |
365 |
| - | |
| 364 | + | |
366 | 365 |
| |
367 | 366 |
| |
368 | 367 |
| |
|
0 commit comments
Comments
(0)