]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Minor fix to day_first_uid updating
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 26 Feb 2017 14:09:13 +0000 (16:09 +0200)
committerGitLab <gitlab@git.dovecot.net>
Thu, 16 Mar 2017 13:05:53 +0000 (15:05 +0200)
mktime() was getting a bit confused around day changes. Giving it only
year/month/day makes it less confused.

src/lib-index/mail-index-transaction-update.c

index e7f903e48c1129f829a3eadbfc0a27e137c1b0d0..82afaf39b9b7732265ff705d07cc1e62208a76cc 100644 (file)
@@ -123,6 +123,7 @@ void mail_index_update_day_headers(struct mail_index_transaction *t,
        struct mail_index_header hdr;
        const struct mail_index_record *rec;
        const int max_days = N_ELEMENTS(hdr.day_first_uid);
+       const struct tm *day_tm;
        struct tm tm;
        time_t stamp;
        int i, days;
@@ -131,10 +132,11 @@ void mail_index_update_day_headers(struct mail_index_transaction *t,
        rec = array_idx(&t->appends, 0);
 
        /* get beginning of today */
-       tm = *localtime(&day_stamp);
-       tm.tm_hour = 0;
-       tm.tm_min = 0;
-       tm.tm_sec = 0;
+       day_tm = localtime(&day_stamp);
+       i_zero(&tm);
+       tm.tm_year = day_tm->tm_year;
+       tm.tm_mon = day_tm->tm_mon;
+       tm.tm_mday = day_tm->tm_mday;
        stamp = mktime(&tm);
        i_assert(stamp != (time_t)-1);