Skip to content

Commit

Permalink
lib-index: Minor fix to day_first_uid updating
Browse files Browse the repository at this point in the history
mktime() was getting a bit confused around day changes. Giving it only
year/month/day makes it less confused.
  • Loading branch information
sirainen authored and GitLab committed Mar 16, 2017
1 parent bb0484f commit b0831ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib-index/mail-index-transaction-update.c
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit b0831ed

Please sign in to comment.