Similar to a previous post I want to get all calendar events that
occurred in the last X hours. However the query does not use
setMinimumStartTime() correctly it seems.
For instance if I set this DateTime to a value this is 7200 hours ago
I don't get calendar entries that are just 5 days old. Yet if I set
it to 72000 hours ago I do get calendar entries that are just 5+ days
old.
Now to calculate a DateTime that is X hours old I simply subtract from
DateTime.now(). I.e.
public DateTimeRange getStartAndEndTime(int hours) {
final DateTime endTime = DateTime.now();
final long startMS = endTime.getValue() - convertHoursToMS
(hours);
return new DateTimeRange(new DateTime(startMS,
endTime.getTzShift()), endTime);
}
The query does not seem to care if I set setMaximumStartTime() to null
or endTime .
My code to create the service and query is taken directly from the
samples. And when I tested with exact dates like is done in the
samples, i.e.
DateTime startTime = DateTime.parseDateTime
("2009-11-23T00:00:00-07:00");
DateTime endTime = DateTime.parseDateTime
("2009-11-24T00:00:00-07:00");
This does seem to work correctly.
So why does the query care how the start DateTime is created? What is
special about it being created from the static parseDateTime method
vs. the constructor?
--
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en.