【问题标题】:Parsing calendar event entry like Google Calendar解析日历事件条目,如谷歌日历
【发布时间】:2016-11-10 22:25:38
【问题描述】:

在 Google 日历中,当您点击日期并输入事件时,它只会要求您在文本字段中输入内容,然后它会自动解释您输入的内容。

比如,我将输入dinner at 7PM7PM dinnerdinner 7PM 等。该应用程序只会理解我正在输入的内容。

这是怎么做到的?

【问题讨论】:

标签: python parsing google-calendar-api


【解决方案1】:
【解决方案2】:

意识到这是一篇旧帖子,但以防万一这对某人有用:这里有更多选项/想法:

选项 1:Python

dateutil 库运行良好:

>> from dateutil.parser import parse
>> parse("tomrrow at 6pm", fuzzy=True)
Out[14]: datetime.datetime(2016, 11, 10, 18, 0)

>> parse("tomrrow at 6pm", fuzzy_with_tokens=True)
Out[15]: (datetime.datetime(2016, 11, 10, 18, 0), ('tomrrow at ',))

选项 2:使用 Google 日历 API

这有点小技巧,但它应该可以工作。你可以使用Google Calendar API's quickAdd:

示例请求:

POST https://www.googleapis.com/calendar/v3/calendars/primary/events/quickAdd?text=Peter%2C+tomorrow+at+8am&key={YOUR_API_KEY}

这将返回一个Event resource,您可以使用此对象中的数据来满足您的需要。

不幸的是,似乎没有办法在不实际在日历中创建事件的情况下调用quickAdd。因此,您需要在创建事件的背景中放置一个一次性的 Google 日历。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多