Julian.fromDateTime constructor
Julian.fromDateTime(
- DateTime utc
Create a Julian date object from a DateTime object. The time contained in the DateTime object is assumed to be UTC.
utc
The UTC time to convert.
Implementation
factory Julian.fromDateTime(DateTime utc) {
double floor(double v) => v.floorToDouble();
final year = utc.year;
final mon = utc.month;
final day = utc.day;
final hr = utc.hour;
final minute = utc.minute;
final sec = utc.second;
final msec = utc.millisecond;
final j = 367.0 * year -
floor(7 * (year + floor((mon + 9) / 12.0)) * 0.25) +
floor(275 * mon / 9.0) +
day +
1721013.5 +
((msec / 60000 + sec / 60.0 + minute) / 60.0 + hr) /
24.0 // ut in days
// # - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
;
return Julian(j);
}