76
76
// did it happen yesterday?
77
GDateTime* tomorrow = g_date_time_add_days(now, -1);
77
GDateTime* yesterday = g_date_time_add_days(now, -1);
78
78
gint tom_year, tom_month, tom_day;
79
g_date_time_get_ymd(yesterday, &tom_year, &tom_month, &tom_day);
80
g_date_time_unref(yesterday);
81
if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) {
82
return DATE_PROXIMITY_YESTERDAY;
85
// does it happen tomorrow?
86
GDateTime* tomorrow = g_date_time_add_days(now, 1);
79
87
g_date_time_get_ymd(tomorrow, &tom_year, &tom_month, &tom_day);
80
88
g_date_time_unref(tomorrow);
81
89
if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) {
82
return DATE_PROXIMITY_YESTERDAY;
85
// does it happen tomorrow?
86
if (prox == DATE_PROXIMITY_FAR)
88
GDateTime* tomorrow = g_date_time_add_days(now, 1);
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;
90
return DATE_PROXIMITY_TOMORROW;
98
93
// 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),
106
if (g_date_time_compare(time, last_week_bound) >= 0)
107
prox = DATE_PROXIMITY_LAST_WEEK;
109
g_date_time_unref(last_week);
110
g_date_time_unref(last_week_bound);
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),
117
if (g_date_time_compare(time, next_week_bound) <= 0)
118
prox = DATE_PROXIMITY_NEXT_WEEK;
120
g_date_time_unref(next_week);
121
g_date_time_unref(next_week_bound);
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),
100
if (g_date_time_compare(time, last_week_bound) >= 0)
101
prox = DATE_PROXIMITY_LAST_WEEK;
103
g_date_time_unref(last_week);
104
g_date_time_unref(last_week_bound);
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),
111
if (g_date_time_compare(time, next_week_bound) <= 0)
112
prox = DATE_PROXIMITY_NEXT_WEEK;
114
g_date_time_unref(next_week);
115
g_date_time_unref(next_week_bound);