【问题标题】:Google Scripts getCalendarsByName to return calendars with similar names谷歌脚本 getCalendarsByName 返回具有相似名称的日历
【发布时间】:2018-11-22 07:13:52
【问题描述】:

我想执行一项功能,该功能允许我仅查询具有特定字符(即“#”)的谷歌日历。

我知道函数 CalendarApp.getCalendarsByName 返回一个日历数组,所以我希望我可以使用这个函数和通配符来返回我想要的日历。我从这里得到了一些关于使用通配符的建议 https://productforums.google.com/forum/#!topic/calendar/gmf6ewpjH4g/

这是目前为止的代码:

function Test() {  
  var pattern = /.*#.*/;
  var calendarsz = CalendarApp.getCalendarsByName(pattern); 
  Logger.log('Found %s matching calendars.', calendarsz.length);
};

但它根本没有返回任何日历。任何有关如何在此函数中使用通配符的建议,或仅返回具有特定字符的日历的替代方法,我们将不胜感激。

【问题讨论】:

    标签: google-apps-script google-api google-calendar-api wildcard


    【解决方案1】:

    getCalendarsByName 方法不支持通配符搜索

    getCalendarsByName(name)

    获取用户拥有或订阅的具有给定名称的所有日历。名称不区分大小写。

    // Gets the public calendar named "US Holidays".
    var calendars = CalendarApp.getCalendarsByName('US Holidays');
    Logger.log('Found %s matching calendars.', calendars.length);
    

    参数

    名称 - 日历名称

    就此而言,Google 日历 API 也不支持它,因此根本无法正常工作。您将不得不全部下载并在本地搜索它们,可能使用 getAllCalendars

    【讨论】:

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