From e722b665d1224e1ea095f366fa021e1d340ba8b9 Mon Sep 17 00:00:00 2001 From: Anthony Parsons Date: Thu, 1 Jan 2015 05:39:36 +0000 Subject: [PATCH] Make "Last seen" handle year rollover correctly --- src/friendlist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/friendlist.c b/src/friendlist.c index c1fb756..2e2519d 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -975,7 +975,10 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m) uint64_t last_seen = Friends.list[f].last_online.last_on; if (last_seen != 0) { - int day_dist = (cur_loc_tm.tm_yday - Friends.list[f].last_online.tm.tm_yday) % 365; + int day_dist = ( + cur_loc_tm.tm_yday - Friends.list[f].last_online.tm.tm_yday + + ((cur_loc_tm.tm_year - Friends.list[f].last_online.tm.tm_year) * 365) + ) % 365; const char *hourmin = Friends.list[f].last_online.hour_min_str; switch (day_dist) {