JavaScript - 如何使用 Google 日历 API 获取特定年份的假期列表?

JavaScript - How to get holiday list of a specific year using Google Calendar API?

我正在使用 Google API v3 检索假期列表,下面是我如何使用 API:https://www.googleapis.com/calendar/v3/calendars/en.usa%23holiday%40group.v.calendar.google.com/events?key=myAPIKey

它return有自己的假期列表(有些是 2021 年,有些是 2022 年),但我想获得我自己特定年份的假期列表。就像我过了 2021 年,那么它将 return 2021 年的所有假期,同样,如果我过了 2022 年,那么它将 return 2022 年。但是我不知道如何传递年份参数,或者我不知道 Google Calendar 是否允许为假期传递这样的参数。

谁能帮帮我?

根据 Google API 文档 https://developers.google.com/calendar/api/v3/reference

有一个 timeMaxtimeMin url 参数接受 date/time 范围:

Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMin is set, timeMax must be greater than timeMin.

https://www.googleapis.com/calendar/v3/calendars/primary/events?q=timeMax=2021-06-03T10%3A00%3A00-07%3A00&timeMin=2011-06-03T10%3A00%3A00-07%3A00

注意: : 被 url 编码为:%3A