100
100
case DateMonth.BAD_MONTH:
101
return "Invalid Month";
101
return _("Invalid Month");
102
102
case DateMonth.JANUARY:
104
104
case DateMonth.FEBRUARY:
105
return _("February");
106
106
case DateMonth.MARCH:
108
108
case DateMonth.APRIL:
110
110
case DateMonth.MAY:
112
112
case DateMonth.JUNE:
114
114
case DateMonth.JULY:
116
116
case DateMonth.AUGUST:
118
118
case DateMonth.SEPTEMBER:
119
return _("September");
120
120
case DateMonth.OCTOBER:
122
122
case DateMonth.NOVEMBER:
123
return _("November");
124
124
case DateMonth.DECEMBER:
125
return _("December");
128
128
return "Internal Error";
131
public string get_day_name (DateWeekday weekday)
135
case GLib.DateWeekday.MONDAY:
137
case GLib.DateWeekday.TUESDAY:
139
case GLib.DateWeekday.WEDNESDAY:
140
return _("Wednesday");
141
case GLib.DateWeekday.THURSDAY:
142
return _("Thursday");
143
case GLib.DateWeekday.FRIDAY:
145
case GLib.DateWeekday.SATURDAY:
146
return _("Saturday");
147
case GLib.DateWeekday.SUNDAY:
150
return "Internal Error";
131
154
/* Calculate the time group of the event returning the group id
132
155
* of the group @event belongs to. It may be necessary for this method
133
156
* to add a row to @groups_model if the group is one of the variadic
134
157
* types such as */
135
public uint get_time_group (Zeitgeist.Event event, Dee.Model groups_model)
158
public uint get_time_group (Zeitgeist.Event event,
159
Dee.Model groups_model,
160
out string comment=null)
137
162
// FIXME: We need to calculate bounds of previous midnight, week, month etc
138
163
// This impl is just a quick hack to have something to show
140
165
var t = event.get_timestamp ();
141
166
var now = Timestamp.now ();
169
debug (@"DELTA: $now - $t = $delta");
143
171
/* Set limit to the previous midnight */
144
172
var limit = Timestamp.prev_midnight (now);
175
/* Fuzzy hour match */
176
var hour = Timestamp.HOUR;
178
if (delta > hour * 7)
179
comment = _("Earlier today");
180
else if (delta > hour * 6)
181
comment = _("Five hours ago");
182
else if (delta > hour * 5)
183
comment = _("Four hours ago");
184
else if (delta > hour * 4)
185
comment = _("Three hours ago");
186
else if (delta > hour * 3)
187
comment = _("Two hours ago");
188
else if (delta > hour * 2)
189
comment = _("1 hour ago");
191
comment = _("Past hour");
147
195
else if (t > limit - Zeitgeist.Timestamp.DAY)
148
return Group.YESTERDAY;
197
comment = _("Yesterday");
198
return Group.YESTERDAY;
150
201
/* Set limit to start of calendar week (monday) */
151
202
var date = Date();
152
203
Timestamp.to_date (now, out date);
153
204
limit = limit - (date.get_weekday() - 1)*Timestamp.DAY;
206
/* Try and give the name of the day */
207
var datethen = Date ();
208
Timestamp.to_date (t, out datethen);
209
comment = get_day_name (datethen.get_weekday ());
155
212
return Group.THIS_WEEK;
156
213
else if (t > limit - Zeitgeist.Timestamp.WEEK)
160
217
date.set_day (1);
161
218
limit = Timestamp.from_date (date);
163
return Group.THIS_MONTH;
221
var days = datethen.days_between (date);
223
/* Try and give a fuzzy weeks time */
225
comment = _("Three weeks ago");
226
else if (days < 7 * 4)
227
comment = _("A month ago");
228
return Group.THIS_MONTH;
231
/* At this point let's just fall back to month name */
232
comment = get_month_name (datethen.get_month ());
165
234
/* Set limit to start of previous calendar month */
166
235
date.subtract_months (1);
167
236
limit = Timestamp.from_date (date);
168
237
if (t > now - 6*30*Zeitgeist.Timestamp.DAY)
169
return Group.PAST_SIX_MONTHS;
239
return Group.PAST_SIX_MONTHS;
171
242
/* Set limit to 1st pf January in the current year. We need to
172
243
* reset 'date' because date.subtract_months(1) above might have