久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Google Apps 腳本日歷服務:僅獲取所有重復(全天)事

Google Apps Script Calendar Service: Get only the first events of all recurring (all day) events(Google Apps 腳本日歷服務:僅獲取所有重復(全天)事件的第一個事件)
本文介紹了Google Apps 腳本日歷服務:僅獲取所有重復(全天)事件的第一個事件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

除了 這個問題 我想問一下如何有效地只檢索所有重復(全天)事件的第一個事件.為每個事件調用函數 findFirstEvent() 似乎不合理.所以我的方法是過濾所有事件的數組.

In addition to this question I'd like to ask how to efficiently retrieve only the first events of all recurring (all day) events. To call the function findFirstEvent() for each single event seems not to be reasonable. So my approach would be to filter the array of all events.

var cal=CalendarApp.getCalendarById("Calendar Id");
var startTime=new Date(1850,0,1);
var endTime=new Date();
var events=cal.getEvents(startTime, endTime);
var firstEvents=events.filter(onlyFirstEvents);

function onlyFirstEvents() {
    ...
}

我最終真正需要的是一個數組,其中事件標題為鍵,Date 對象為值.

What I actually need in the end is an array with the event titles as keys and Date objects as values.

推薦答案

  • 您想從 Google 日歷中檢索所有定期活動和全天活動.
  • 特別是,您要檢索重復事件的開始事件的日期對象.
  • 您希望使用 Google Apps 腳本實現此目的.
  • 如果我的理解是正確的,那么這個答案呢?請認為這只是幾個可能的答案之一.

    If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.

    • 本例使用isRecurringEvent()isAllDayEvent()方法.
    • getEvents() 按降序返回事件.使用它,可以檢索到您期望的結果.
    • In this case, the methods of isRecurringEvent() and isAllDayEvent() are used.
    • getEvents() returns the events with the descending order. Using this, the result you expect is retrieved.

    當以上幾點反映到你的腳本中時,它變成如下.

    When above points are reflected to your script, it becomes as follows.

    var firstEvents=events.filter(onlyFirstEvents);
    

    到:

    var firstEvents = events.reduce(function(ar, e) {
      var id = e.getId();
      if (e.isRecurringEvent() && e.isAllDayEvent() && !ar.some(function(f) {return f.eventId == id})) {
        ar.push({eventTitle: e.getTitle(), eventId: id, startDate: e.getAllDayStartDate(), endDate: e.getAllDayEndDate()});
      }
      return ar;
    }, []);
    

    結果:

    運行上述腳本時,返回以下值.

    Result:

    When above script is run, the following value is returned.

    [
      {
        "eventTitle": "###",
        "eventId": "###",
        "startDate": ### date object ###,
        "endDate": ### date object ###
      },
    ,
    ,
    
    ]
    

    參考資料:

    • isRecurringEvent()
    • isAllDayEvent()李>
    • getId()
    • 如果我誤解了您的問題并且這不是您想要的方向,我深表歉意.

      If I misunderstood your question and this was not the direction you want, I apologize.

      • 所以你會 for 循環遍歷結果數組 firstEvents 以獲取所需的數組,其中事件標題作為鍵,日期對象作為值?

      由此,我無法理解您想要一個數組還是一個對象.所以我想提出2種模式.在這種情況下,我認為可以使用當前腳本的firstEvents.

      From this, I cannot understand whether you want an array or an object. So I would like to propose 2 patterns. In this case, I thought that firstEvents of the current script can be used.

      在此模式中,返回一個數組,其中包括事件標題和開始日期對象分別是鍵和值.請進行如下修改.

      In this pattern, an array, which includes that the event titles and the start date object are the key and value, respectively, is returned. Please modify as follows.

      var firstEvents = events.reduce(function(ar, e) {
        var id = e.getId();
        if (e.isRecurringEvent() && e.isAllDayEvent() && !ar.some(function(f) {return f.eventId == id})) {
          ar.push({eventTitle: e.getTitle(), eventId: id, startDate: e.getAllDayStartDate(), endDate: e.getAllDayEndDate()});
        }
        return ar;
      }, []);
      firstEvents = firstEvents.map(function(e) {
        var obj = {};
        obj[e.eventTitle] = e.startDate;
        return obj;
      });
      

      模式2:

      在此模式中,返回一個對象,其中包括事件標題和開始日期對象分別是鍵和值.

      Pattern 2:

      In this pattern, an object, which includes that the event titles and the start date object are the key and value, respectively, is returned.

      var firstEvents = events.reduce(function(ar, e) {
        var id = e.getId();
        if (e.isRecurringEvent() && e.isAllDayEvent() && !ar.some(function(f) {return f.eventId == id})) {
          ar.push({eventTitle: e.getTitle(), eventId: id, startDate: e.getAllDayStartDate(), endDate: e.getAllDayEndDate()});
        }
        return ar;
      }, []);
      firstEvents = firstEvents.reduce(function(obj, e) {
        obj[e.eventTitle] = e.eventTitle in obj ? obj[e.eventTitle].concat(e.startDate) : [e.startDate];
        return obj;
      }, {});
      

      這篇關于Google Apps 腳本日歷服務:僅獲取所有重復(全天)事件的第一個事件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

      【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 天天操综合网 | 天天色天天色 | 91免费看片 | 日韩在线播放av | 成人在线观看免费 | 成人国产免费视频 | 精品一区二区三区在线视频 | 日本又色又爽又黄又高潮 | 欧美性video 精品亚洲一区二区 | 日韩免费一级 | 午夜亚洲| av第一页 | 国产欧美一级 | 欧美不卡视频一区发布 | 久久草在线视频 | 一级免费黄色 | 中文日韩在线视频 | 欧美视频日韩 | 亚洲精品视频在线看 | 亚洲综合视频一区 | www中文字幕 | 国产欧美在线一区二区 | 亚洲一区二区三区视频 | 成年人视频在线免费观看 | 精品一区二区三区在线观看 | 国产精品一二三区在线观看 | 成人免费一区二区三区视频网站 | 国产高清一区 | 一区二区三区av夏目彩春 | 亚洲国产精品久久久 | 久久一二区 | 黑人精品欧美一区二区蜜桃 | 人人看人人爽 | 超碰男人天堂 | caoporn免费在线视频 | 成人免费网站视频 | 毛片区| 成人黄色三级毛片 | 欧美色综合 | 成人性视频免费网站 | 91在线看 |