toJulian static method
公历转儒略日,UTC=1表示原日期是UTC
@param UTC UTC @return 公历转儒略日, UTC=1表示原日期是UTC
Implementation
static double toJulian(Time time, bool UTC) {
double y = time.year; // 取出年月
double m = time.month;
double n = 0;
if (m <= 2) {
m += 12;
y--;
}
if (time.year * 372 + time.month * 31 + time.day >= 588829) {
// 判断是否为格里高利历日1582*372+10*31+15
n = doubleFloor(y / 100);
n = 2 - n + doubleFloor(n / 4); // 加百年闰
}
n += doubleFloor(365.2500001 * (y + 4716)); // 加上年引起的偏移日数
n += doubleFloor(30.6 * (m + 1)) + time.day; // 加上月引起的偏移日数及日偏移数
n += ((time.second / 60 + time.minute) / 60 + time.hour) / 24 - 1524.5;
if (UTC) return n + atomTimeDiff(n - J2000);
return n;
}