]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Fix days_since_epoch to year_yday calculation
authorWillem Toorop <willem@NLnetLabs.nl>
Fri, 23 Dec 2011 21:13:56 +0000 (21:13 +0000)
committerWillem Toorop <willem@NLnetLabs.nl>
Fri, 23 Dec 2011 21:13:56 +0000 (21:13 +0000)
util.c

diff --git a/util.c b/util.c
index 01d29c104fce15eef339b965eda2f7ad3d3d5de4..1410c44c0949a331bf17869cca30b4659e5a1282 100644 (file)
--- a/util.c
+++ b/util.c
@@ -256,7 +256,9 @@ ldns_year_and_yday_from_days_since_epoch(int64_t days, struct tm *result)
        int new_year;
 
        while (days < 0 || days >= (int64_t) (is_leap_year(year) ? 366 : 365)) {
-               new_year = year + (int) LDNS_DIV(days, 366);
+               new_year = year 
+                        + (int) LDNS_DIV( days
+                                        , is_leap_year(year) ? 366 : 365 );
                if (year == new_year) {
                        year += days < 0 ? -1 : 1;
                }