儒略日:
static inline int64_t floordiv(int64_t a, int b)
{
return (a - (a < 0 ? b - 1 : 0)) / b;
}
static inline int floordiv(int a, int b)
{
return (a - (a < 0 ? b - 1 : 0)) / b;
}
// 当前的日期对应的儒略日
static inline int64_t julianDayFromDate(int year, int month, int day)
{
// Adjust for no year 0
if (year < 0)
{
++year;
}
/*
* Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php
* This formula is correct for all julian days, when using mathematical integer
* division (round to negative infinity), not c++11 integer division (round to zero)
*/
int a = floordiv(14 - month, 12