Gregorian.fromJulianDayNumber constructor
Gregorian.fromJulianDayNumber(
- int julianDayNumber
Calculates Gregorian and Julian calendar dates from the Julian Day number
julianDayNumber
for the period since jdn=-34839655
(i.e. the year -100100 of both calendars)
to some millions years ahead of the present.
Implementation
factory Gregorian.fromJulianDayNumber(final int julianDayNumber) {
if (julianDayNumber < 1925675 || julianDayNumber > 3108616) {
throw DateException('Julian day number is out of computable range.');
}
final int j = 4 * julianDayNumber +
139361631 +
((((4 * julianDayNumber + 183187720) ~/ 146097) * 3) ~/ 4) * 4 -
3908;
final int i = (((j % 1461)) ~/ 4) * 5 + 308;
final int gd = (((i % 153)) ~/ 5) + 1;
final int gm = (((i) ~/ 153) % 12) + 1;
final int gy = ((j) ~/ 1461) - 100100 + ((8 - gm) ~/ 6);
return Gregorian(gy, gm, gd);
}