@@ -74,53 +74,45 @@ getDateProximity(GDateTime* now, GDateTime* time)
7474 }
7575
7676 // did it happen yesterday?
77− GDateTime* tomorrow = g_date_time_add_days(now, -1);
77+ GDateTime* yesterday = g_date_time_add_days(now, -1);
7878 gint tom_year, tom_month, tom_day;
79− g_date_time_get_ymd(tomorrow, &tom_year, &tom_month, &tom_day);
80− g_date_time_unref(tomorrow);
79+ g_date_time_get_ymd(yesterday, &tom_year, &tom_month, &tom_day);
80+ g_date_time_unref(yesterday);
8181 if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) {
8282 return DATE_PROXIMITY_YESTERDAY;
8383 }
8484
8585 // does it happen tomorrow?
86− if (prox == DATE_PROXIMITY_FAR)
87− {
88− GDateTime* tomorrow = g_date_time_add_days(now, 1);
89−
90− gint tom_year, tom_month, tom_day;
91− g_date_time_get_ymd(tomorrow, &tom_year, &tom_month, &tom_day);
92− g_date_time_unref(tomorrow);
93− if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) {
94− return DATE_PROXIMITY_TOMORROW;
95− }
86+ GDateTime* tomorrow = g_date_time_add_days(now, 1);
87+ g_date_time_get_ymd(tomorrow, &tom_year, &tom_month, &tom_day);
88+ g_date_time_unref(tomorrow);
89+ if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) {
90+ return DATE_PROXIMITY_TOMORROW;
9691 }
9792
9893 // does it happen this week?
99− if (prox == DATE_PROXIMITY_FAR) {
100− if (g_date_time_compare(time, now) < 0) {
101− GDateTime* last_week = g_date_time_add_days(now, -6);
102− GDateTime* last_week_bound = g_date_time_new_local(g_date_time_get_year(last_week),
103− g_date_time_get_month(last_week),
104− g_date_time_get_day_of_month(last_week),
105− 0, 0, 0);
106− if (g_date_time_compare(time, last_week_bound) >= 0)
107− prox = DATE_PROXIMITY_LAST_WEEK;
108−
109− g_date_time_unref(last_week);
110− g_date_time_unref(last_week_bound);
111− } else {
112− GDateTime* next_week = g_date_time_add_days(now, 6);
113− GDateTime* next_week_bound = g_date_time_new_local(g_date_time_get_year(next_week),
114− g_date_time_get_month(next_week),
115− g_date_time_get_day_of_month(next_week),
116− 23, 59, 59.9);
117− if (g_date_time_compare(time, next_week_bound) <= 0)
118− prox = DATE_PROXIMITY_NEXT_WEEK;
119−
120− g_date_time_unref(next_week);
121− g_date_time_unref(next_week_bound);
122− }
123−
94+ if (g_date_time_compare(time, now) < 0) {
95+ GDateTime* last_week = g_date_time_add_days(now, -6);
96+ GDateTime* last_week_bound = g_date_time_new_local(g_date_time_get_year(last_week),
97+ g_date_time_get_month(last_week),
98+ g_date_time_get_day_of_month(last_week),
99+ 0, 0, 0);
100+ if (g_date_time_compare(time, last_week_bound) >= 0)
101+ prox = DATE_PROXIMITY_LAST_WEEK;
102+
103+ g_date_time_unref(last_week);
104+ g_date_time_unref(last_week_bound);
105+ } else {
106+ GDateTime* next_week = g_date_time_add_days(now, 6);
107+ GDateTime* next_week_bound = g_date_time_new_local(g_date_time_get_year(next_week),
108+ g_date_time_get_month(next_week),
109+ g_date_time_get_day_of_month(next_week),
110+ 23, 59, 59.9);
111+ if (g_date_time_compare(time, next_week_bound) <= 0)
112+ prox = DATE_PROXIMITY_NEXT_WEEK;
113+
114+ g_date_time_unref(next_week);
115+ g_date_time_unref(next_week_bound);
124116 }
125117
126118 return prox;
@@ -250,7 +242,7 @@ char* generate_full_format_string_at_time (GDateTime* now,
250242
251243QString RelativeTimeFormatter::format() const
252244{
253− GDateTime* now = g_date_time_new_from_unix_utc(QDateTime::currentMSecsSinceEpoch() / 1000);
245+ GDateTime* now = g_date_time_new_now_local();
254246 if (!now) { return QString(); }
255247
256248 GDateTime* then = g_date_time_new_from_unix_local(time());