diff options
author | Chenthill Palanisamy <pchenthill@novell.com> | 2009-09-10 17:01:36 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchenthill@novell.com> | 2009-09-10 17:05:41 +0800 |
commit | b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f (patch) | |
tree | 8d63063d5143124fb4d871ec5393f96945a000e1 | |
parent | 87564151762fb3fdf62fe0a753d8718ad1c0788d (diff) | |
download | gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar.gz gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar.bz2 gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar.lz gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar.xz gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.tar.zst gsoc2013-evolution-b9885f8cf9a9c4ee14e5af13a6323d1bc85e541f.zip |
Bug #594609 - Date field in message list shows incorrect "x days ago".
-rw-r--r-- | e-util/e-datetime-format.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 6dff77f2ee..2e632317fa 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -171,13 +171,18 @@ static gchar * format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, const struct tm *today) { gchar *res = g_strdup (get_default_format (DTFormatKindDate, NULL)); + GDate now, val; + gint diff; g_return_val_if_fail (value != NULL, res); g_return_val_if_fail (today != NULL, res); + g_date_set_time_t (&now, ttoday); + g_date_set_time_t (&val, tvalue); + + diff = g_date_get_julian (&now) - g_date_get_julian (&val); /* if it's more than a week, use the default date format */ - if (ttoday - tvalue > 7 * 24 * 60 * 60 || - tvalue - ttoday > 7 * 24 * 60 * 60) + if (ABS (diff) > 7) return res; g_free (res); @@ -187,14 +192,11 @@ format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, cons value->tm_mday == today->tm_mday) { res = g_strdup (_("Today")); } else { - gint diff = (gint) (tvalue - ttoday); - gint since_midnight = today->tm_sec + (60 * today->tm_min) + (60 * 60 * today->tm_hour); - gboolean future = (diff > 0); + gboolean future = FALSE; - if (!future) - diff *= -1; + if (diff < 0) + future = TRUE; - diff = (diff - since_midnight) / (24 * 60 * 60); if (diff <= 1) { if (future) res = g_strdup (_("Tomorrow")); |