40
40
#define __DAYS_IN_MONTH(y, c) (const uint32_t *) (IS_LEAP_YEAR((y),(c)) ? __leap_days_in_month : __normal_days_in_month)
41
41
#define __DAYS_TO_END_MONTH(y, c) (const uint32_t *) (IS_LEAP_YEAR((y),(c)) ? __leap_days_to_end_month : __normal_days_to_end_month)
44
* Calculates the Julian Day Number from the year, month
45
* and day at noon supplied in the Julian calendar.
47
* The following formula is used to calculate the Julian
48
* Day Number from a date in the Julian Calendar.
50
* The months January to December are 1 to 12.
51
* Astronomical year numbering is used, thus 1 BC is 0, 2 BC is −1,
52
* and 4713 BC is −4712. In all divisions (except for JD) the floor
53
* function is applied to the quotient (for dates since
54
* March 1, −4800 all quotients are non-negative, so we can also
57
* a = (14 - month) / 12
60
* JDN = day + ((153m + 2) / 5) + 365y + (y / 4) - 32083
62
* @cite http://en.wikipedia.org/wiki/Julian_day#Calculation
66
* Year month and day values are assumed to be valid. This
67
* method does no bounds checking or validation.
70
* @param Month of date
73
int64_t julian_day_number_from_julian_date(uint32_t year, uint32_t month, uint32_t day)
76
int64_t a= (14 - month) / 12;
77
int64_t y= year + 4800 - a;
78
int64_t m= month + (12 * a) - 3;
80
day_number= day + (((153 * m) + 2) / 5) + (365 * y) + (y / 4) - 32083;
85
45
* Calculates the Julian Day Number from the year, month