代表一系列活動的重複規則。
請注意,這個類別的行為也與所屬的 EventRecurrence 類似,
可讓您將規則建立作業串連在一起,如下所示:
const recurrence = CalendarApp.newRecurrence().addDailyRule().times(3).interval(2).addWeeklyExclusion().times(2);
times(times) 和 interval(interval) 等修飾符會套用至最近新增的規則。方法
內容詳盡的說明文件
addDailyExclusion()
新增規則,每天排除特定情況。
// Creates a rule that recurs every week after the first 30 days. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().addDailyExclusion().times(30);
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addDailyRule()
新增規則,讓活動每天重複。
// Creates a rule that recurs every day for ten days. const recurrence = CalendarApp.newRecurrence().addDailyRule().times(10);
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addDate(date)
新增規則,讓活動在特定日期重複發生。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
date | Date |
回攻員
EventRecurrence - 用於串連的 EventRecurrence
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addDateExclusion(date)
新增規則,排除特定日期的活動。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
date | Date |
回攻員
EventRecurrence - 用於串連的 EventRecurrence
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addMonthlyExclusion()
新增規則,每月排除特定日期。
根據預設,系統會在系列活動中第一個活動的當月同一天套用排除條件,但您可以呼叫 onlyOnMonthDay(day) 或 onlyOnMonthDays(days) 變更此設定。
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addMonthlyRule()
新增規則,讓活動每月重複發生。
根據預設,系統會將系列活動中第一個活動的日期設為重複日期,但您可以呼叫 onlyOnMonthDay(day) 或 onlyOnMonthDays(days) 變更這項設定。
// Creates a rule that recurs every month for three months. const recurrence = CalendarApp.newRecurrence().addMonthlyRule().times(4);
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addWeeklyExclusion()
新增每週排除例外的規則。
根據預設,系統會在系列活動中第一個活動的同一天套用排除條件,但可以呼叫 onlyOnWeekday(day) 或 onlyOnWeekdays(days) 變更。
// Creates a rule that recurs every day except the first four Wednesdays. const recurrence = CalendarApp.newRecurrence() .addDailyRule() .addWeeklyExclusion() .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY) .times(4);
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addWeeklyRule()
新增規則,讓活動每週重複發生。
根據預設,活動會在系列中第一個活動的同一天重複發生,但可以呼叫 onlyOnWeekday(day) 或 onlyOnWeekdays(days) 變更。
// Creates a rule that recurs every week for ten weeks. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().times(10);
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addYearlyExclusion()
新增每年排除特定日期的規則。
根據預設,系統會在系列活動中第一個活動的當天套用排除條件,但您可以呼叫 onlyOnYearDay(day) 或 onlyOnYearDays(days) 變更這項設定。
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
addYearlyRule()
新增規則,讓活動每年重複發生。
根據預設,系統會將活動的每年重複日期設為系列活動中第一個活動的日期,
但您可以呼叫 onlyOnYearDay(day) 或 onlyOnYearDays(days) 變更這項設定。
回攻員
RecurrenceRule:新的 RecurrenceRule
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
interval(interval)
設定規則,使其只在規則時間單位的這個間隔套用。
// Creates a rule that recurs every fourth week. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().interval(4);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
interval | Integer | 規則時間單位的間隔 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyInMonth(month)
設定規則,只在特定月份生效。
// Creates a rule that recurs every week in February. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyInMonth( CalendarApp.Month.FEBRUARY);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
month | Month | 當月 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyInMonths(months)
設定規則,只在特定月份套用。
// Creates a rule that recurs every week in February and March. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyInMonths( [CalendarApp.Month.FEBRUARY, CalendarApp.Month.MARCH]);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
months | Month[] | 月份 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnMonthDay(day)
設定規則,只在每月的特定日期套用。
// Creates a rule that recurs every month on the fifth day of the month. const recurrence = CalendarApp.newRecurrence().addMonthlyRule().onlyOnMonthDay(5);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
day | Integer | 當月第幾日 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnMonthDays(days)
設定規則,只在每月的特定日期套用。
// Creates a rule that recurs every month on the first and fifteenth day of the // month. const recurrence = CalendarApp.newRecurrence().addMonthlyRule().onlyOnMonthDays([1, 15]);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
days | Integer[] | 當月第幾天 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnWeek(week)
設定規則,只套用至一年中的特定週次。
// Creates a rule that recurs on the fifth week of every year. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeek(5);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
week | Integer | 當週 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnWeekday(day)
設定規則,只在一週的特定一天套用。
// Creates a rule that recurs every week on Wednesdays. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday( CalendarApp.Weekday.WEDNESDAY);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
day | Weekday | 星期幾 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnWeekdays(days)
設定規則,只在一週內的某幾天套用。
// Creates a rule that recurs every week on Tuesdays and Thursdays. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekdays( [CalendarApp.Weekday.TUESDAY, CalendarApp.Weekday.THURSDAY]);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
days | Weekday[] | 星期幾 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnWeeks(weeks)
設定規則,只在一年中的特定週套用。
// Creates a rule that recurs on the fifth and tenth weeks of every year. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeeks([5, 10]);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
weeks | Integer[] | 週 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnYearDay(day)
設定規則,只在一年中的特定日期套用。
// Creates a rule that recurs every year on February 15 (the 46th day). const recurrence = CalendarApp.newRecurrence().addYearlyRule().onlyOnYearDay(46);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
day | Integer | 一年中的第幾天 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
onlyOnYearDays(days)
設定規則,只在一年中的特定日期套用。
// Creates a rule that recurs every year on January 20 and February 15. const recurrence = CalendarApp.newRecurrence().addYearlyRule().onlyOnYearDay([20, 46]);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
days | Integer[] | 一年中的第幾天 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
setTimeZone(timeZone)
設定這項週期性事件的時區。這會影響活動的週期性日期和時間, 以及活動是否會隨著日光節約時間調整。預設為日曆時區。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
time | String | 時區,以「long」格式指定 (例如「America/New_York」,如 Joda.org 所列) |
回攻員
EventRecurrence - 用於串連的 EventRecurrence
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
times(times)
設定規則,在達到指定次數後結束。
// Creates a rule that recurs every day for ten days. const recurrence = CalendarApp.newRecurrence().addDailyRule().times(10);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
times | Integer | 重複次數 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
until(endDate)
設定規則,在指定日期 (含該日期) 結束。
// Creates a rule that recurs every day through the end of 2013. const recurrence = CalendarApp.newRecurrence().addDailyRule().until( new Date('December 31, 2013'));
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
end | Date |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
weekStartsOn(day)
設定一週的起始日,以套用規則。
// Creates a weekly rule where weeks start on Monday. const recurrence = CalendarApp.newRecurrence().addWeeklyRule().weekStartsOn( CalendarApp.Weekday.MONDAY);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
day | Weekday | 一週的起始日 |
回攻員
RecurrenceRule - 這個 RecurrenceRule 用於鏈結