igr / julian-day

Precise Julian Day Java library
BSD 2-Clause "Simplified" License
4 stars 0 forks source link

JulianDay is inconsistent across versions #3

Closed zabetak closed 3 months ago

zabetak commented 3 months ago

The date 2023-05-23 in previous releases it was mapped to the Julian day 2460088 while now (7.0.0) it is mapped to either 2460087 or 2460100.

org.jodd:jodd-core:3.5.2

import jodd.datetime.JDateTime;
new JDateTime(2023,5,23).getJulianDayNumber() //2460088 

org.jodd:jodd-util:6.0.0

import jodd.time.JulianDate;
JulianDate.of(LocalDate.of(2023,5,23)).getJulianDayNumber() //2460088 

org.jodd:julian-day:7.0.0

import jodd.julianday.JulianDateTime;
import jodd.julianday.JulianDay;
JulianDay.ofGregorianDate(LocalDate.of(2023,5,23)).day() //2460087
JulianDay.ofJulianDate(new JulianDateTime(2023,5,23,0,0,0,0)).day() //2460100 

I am not sure which number is the correct one but the fact they are different creates compatibility problems when data are persistent and reading/writing is performed cross versions.

igr commented 3 months ago

No worries, I know what it is. I will add a method shortly and release it!

The old getJulianDayNumber() is just the integer number of a day, but with a little twist (as Julian days start at noon). I will add a similar method to the new library.

You probably do not need Julian calendar dates. If you were not considering them explicitly, just use "gregorian" methods.

igr commented 3 months ago

The thing is that day() is not JDN. Added a method that calculates the jdn.

igr commented 3 months ago

Published 7.1.0