【发布时间】:2018-06-08 17:01:24
【问题描述】:
我一直在尝试创建查询参数来设置开始日期/时间和结束日期/时间以从标签/链接添加到 Google 日历。
我的查询参数如下:
`https://calendar.google.com/calendar/r/eventedit?text=${Title}&dates=${event.Year}${
Months.findIndex(e => e === Month) < 10
? `0${Months.findIndex(e => e === Month)}`
: Months.findIndex(e => e === Month)
}${event.Day}${StartTime}T120000Z/${EndYear}${
Months.findIndex(e => e === EndMonth) < 10
? `0${Months.findIndex(e => e === EndMonth)}`
: Months.findIndex(e => e === EndMonth)
}${EndDay}${EndTime}T130000Z&sf=true&output=xml`
如果我删除开始/结束时间变量,那么它将成功加载页面并显示正确的开始日期,但结束日期不会显示。老实说,我不明白T130000Z 但没有它就行不通。
它重定向到的链接(部分有效)如下:
https://calendar.google.com/calendar/r/eventedit?text=Class%20of%202018%20graduation%20celebration&dates=20181212T120000Z/20180426T130000Z&sf=true&output=xml
根据@StephenP 的评论,我更新了查询以包含时间。
我将T120000Z 更改为 T${StartTime.split(':').join('')}00Z 成功将T010100Z 添加到网址中。
但是,尽管如此,日历页面不会更新除标题之外的任何字段。只是默认为今天的日期。
【问题讨论】:
-
T及以下为时间表示,可以在several formats中。T120000Z因为 hhmmss 将是 12:00:00,而Z表示这是在“zulu time”(UTC)中。关于ISO 8601 日期和时间格式的维基百科文章提供了非常丰富的信息。 -
伙伴,这也可以在不提供 [T
] 参数的情况下工作
标签: javascript date url parameters