26 return ((year % 4) == 0) &&
27 (!(((year % 100) == 0) && ((year % 400) != 0)));
32 #define GREGORIAN_EPOCH 1721425.5 37 (365.0 * (year - 1.0)) +
38 floor((year - 1.0) / 4.0) +
39 (-floor((year - 1.0) / 100.0)) +
40 floor((year - 1.0) / 400.0) +
41 floor((((367.0 * month) - 362.0) / 12.0) +
50 static double mod(
double a,
double b)
52 return a - (b * floor(a / b));
75 wjd = floor(jd - 0.5) + 0.5;
77 quadricent = floor(depoch / 146097);
78 dqc =
mod(depoch, 146097);
79 cent = (int)floor(dqc / 36524);
80 dcent =
mod(dqc, 36524);
81 quad = floor(dcent / 1461);
82 dquad =
mod(dcent, 1461);
83 yindex = (int)floor(dquad / 365);
84 year = (int)((quadricent * 400) + (cent * 100) + (quad * 4) + yindex);
85 if (!((cent == 4) || (yindex == 4))) {
91 month = (int)floor((((yearday + leapadj) * 12) + 373) / 367);
101 static void jhms(
double j,
int *hour,
int *
min,
int *sec)
106 ij = (int)(((j - floor(j)) * 86400.0) + 0.5);
107 *hour = (int)floor(ij / 3600);
108 *min = (int)floor((ij / 60) % 60);
109 *sec = (int)floor(ij % 60);
137 if (year == NULL || month == NULL || day == NULL ||
138 hour == NULL || min == NULL || sec == NULL)
145 jhms(jd,hour,min,sec);
static void jd_to_gregorian(double jd, int *y, int *m, int *d)
#define MTK_ERR_CODE_JUMP(code)
static double mod(double a, double b)
static int leap_gregorian(int year)
MTKt_status MtkJulianToCal(double jd, int *year, int *month, int *day, int *hour, int *min, int *sec)
Convert Julian date to calendar date.
static double gregorian_to_jd(int year, int month, int day)
static void jhms(double j, int *hour, int *min, int *sec)