儒略日
C/C++
// 儒略日 C++14
auto toJulianDay(int year, int month, int day) -> int {
const int adj = (14 - month) / 12;
const int y = year + 4800 - adj;
const int m = month + 12 * adj - 3;
return day + (153 * m + 2) / 5 + y * 365 + y / 4 - y / 100 + y / 400 - 32045;
}
Golang
// 儒略日
func toJulianDay(year int, month int, day int) int {
adj := (14 - month) / 12
y := year + 4800 - adj
m := month + 12*adj - 3
return day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045
}
Python
# 儒略日
def to_julian_day(year: int, month: int, day: int) -> int:
adj = (14 - month) // 12
y = year + 4800 - adj
m = month + 12 * adj - 3
return day + (153 * m + 2) // 5 + y * 365 + y // 4 - y // 100 + y // 400 - 32045
标签:int,month,儒略,算法,year,adj,day
From: https://www.cnblogs.com/gjycn/p/16852938.html