【问题标题】:Google Calendar's EventQuery not retrieving correct entries谷歌日历事件查询没有检索到正确的条目
【发布时间】:2011-07-14 03:06:43
【问题描述】:

我正在尝试使用Google's .NET Calendar API retrieve 南非公共假期。

我有以下问题:

  1. 某些检索到的数据超出了指定的EventQuery 范围。 (在给定日期范围之前和之后)
  2. 缺少一些日历条目。其中之一是圣诞节 2011-12-25

我通过查看online 验证了这个特定的公共日历的日期正确。

我的最佳猜测是我错误地使用了 API,并且我正在查询诸如日历条目的创建/更新日期而不是事件日期之类的内容。

代码:

var feedUrl = "http://www.google.com/calendar/feeds/en.sa%23holiday%40group.v.calendar.google.com/public/full";
var service = new CalendarService("My application name");

var qry       = new EventQuery(feedUrl);
qry.StartDate = new DateTime(2011, 1, 1);
qry.EndDate   = new DateTime(2012, 1, 1);

EventFeed results = service.Query(qry);

foreach (EventEntry entry in results.Entries)
{
    if (entry.Times.Count == 0)  
       continue;

    // Using entry.Times[0].StartTime results in 
    // missing data and data outside of the given search criteria.
}

我正在使用最新可用的Google .NET Data API 1.7.0.1

我做错了什么?

【问题讨论】:

    标签: .net google-calendar-api gdata-api


    【解决方案1】:

    发现问题:

    qry.StartDate = new DateTime(2011, 1, 1);
    qry.EndDate   = new DateTime(2012, 1, 1);
    

    应该是:

    qry.StartTime = new DateTime(2011, 1, 1);
    qry.EndTime   = new DateTime(2012, 1, 1);
    

    这解决了我在问题中提到的两个问题。 (不知道为什么EventQuery 类同时具有日期/时间属性,当只有一组有效时,这会令人困惑)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多