diff --git a/src/mtime_timedelta.c b/src/mtime_timedelta.c index 2e1ac706d5c58c9a1f30a88cb40d9624cd4b1697..9ca234856eccf410b1a45d72aa24b156418ff888 100644 --- a/src/mtime_timedelta.c +++ b/src/mtime_timedelta.c @@ -805,6 +805,16 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc int64_t j = base_dt->date.year; /* Initialize to 0. */ td_return->year = 0; + + /* Fast-Fwd: >= 400 */ + while (days >= NO_OF_DAYS_IN_400_YEARS) + { + td_return->year = td_return->year + 400; + j = j + 400; + days = days - NO_OF_DAYS_IN_400_YEARS; + + }; + do { @@ -895,6 +905,16 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc int64_t j = base_dt->date.year; /* Initialize. */ td_return->year = 0; + + /* Fast-Fwd: >= 400 */ + while (days >= NO_OF_DAYS_IN_400_YEARS) + { + td_return->year = td_return->year + 400; + j = j - 400; + days = days - NO_OF_DAYS_IN_400_YEARS; + + }; + do { /* Loop over and get the year by substracting 366/365 days depending