久久久久久久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| 成人影院免费视频 | 国产精品爱久久久久久久 | 亚洲高清视频在线观看 | 日日操夜夜干 | 日韩精品一二三 | 免费在线一区二区 | 久久国产精品免费视频 | 91麻豆精品国产91久久久更新资源速度超快 | 亚洲国产aⅴ成人精品无吗 综合国产在线 | 成人免费大片黄在线播放 | 亚洲av毛片成人精品 | 欧美一区中文字幕 | 亚洲一区播放 | 亚洲影音先锋 | 免费观看a级毛片在线播放 黄网站免费入口 | 亚洲欧美v | 国产精品中文字幕一区二区三区 | 男人av在线播放 | 97精品国产手机 | av天天干 | 日韩一区二区av | 人成久久 | 欧美日韩精品影院 | 色频 | 亚洲精品久久久久久下一站 | 亚洲高清网 | 成人美女免费网站视频 | 激情小说综合网 | 五月综合激情在线 | 亚洲午夜网 | 日韩中文字幕高清 | 天天干视频在线 | 粉嫩一区二区三区四区公司1 |