Commit 544e97bf authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak

timestamp-label: Unbreak relative days and months

Phones have a long uptime so fall back to pure date printing
after 1y.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 83821678
...@@ -159,25 +159,21 @@ phosh_time_diff_in_words (GDateTime *dt, GDateTime *dt_now) ...@@ -159,25 +159,21 @@ phosh_time_diff_in_words (GDateTime *dt, GDateTime *dt_now)
prefix = str_about; prefix = str_about;
number = 1; number = 1;
unit = str_day; unit = str_day;
show_date = TRUE;
break; break;
case 2530 ... 43199: case 2530 ... 43199:
prefix = ""; prefix = "";
number = days; number = days;
unit = str_days; unit = str_days;
show_date = TRUE;
break; break;
case 43200 ... 86399: case 43200 ... 86399:
prefix = str_about; prefix = str_about;
number = 1; number = 1;
unit = str_month; unit = str_month;
show_date = TRUE;
break; break;
case 86400 ... 525600: case 86400 ... 525600:
prefix = ""; prefix = "";
number = months; number = months;
unit = str_months; unit = str_months;
show_date = TRUE;
break; break;
default: default:
......
...@@ -106,6 +106,31 @@ test_phosh_time_diff_in_words (void) ...@@ -106,6 +106,31 @@ test_phosh_time_diff_in_words (void)
str = phosh_time_diff_in_words (dt, dt_now); str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "~2h"); g_assert_cmpstr (str, ==, "~2h");
g_date_time_unref (dt);
dt = g_date_time_new_local (2020, 12, 30, 21, 00, 00);
str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "~1d");
g_date_time_unref (dt);
dt = g_date_time_new_local (2020, 12, 29, 21, 00, 00);
str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "2d");
g_date_time_unref (dt);
dt = g_date_time_new_local (2020, 11, 29, 21, 00, 00);
str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "~1mo");
g_date_time_unref (dt);
dt = g_date_time_new_local (2020, 10, 29, 21, 00, 00);
str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "2mos");
g_date_time_unref (dt);
dt = g_date_time_new_local (2019, 12, 31, 21, 00, 00);
str = phosh_time_diff_in_words (dt, dt_now);
g_assert_cmpstr (str, ==, "12/31/19");
/* Restore previous locale */ /* Restore previous locale */
uselocale (save_locale); uselocale (save_locale);
freelocale (locale); freelocale (locale);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment