{"id":3365,"date":"2021-04-28T16:50:35","date_gmt":"2021-04-28T07:50:35","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=3365"},"modified":"2021-04-28T16:50:35","modified_gmt":"2021-04-28T07:50:35","slug":"post-3365","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/3365","title":{"rendered":"GAS\u3067Google\u30ab\u30ec\u30f3\u30c0\u30fc\u3068\u9023\u643a\u3057\u3066\u30a4\u30d9\u30f3\u30c8\u306e\u53d6\u5f97\u30fb\u8ffd\u52a0\u30fb\u524a\u9664"},"content":{"rendered":"<p>Google Apps Script\u306e\u52c9\u5f37\u3068\u3057\u3066Google\u30ab\u30ec\u30f3\u30c0\u30fc\u3068\u9023\u643a\u3055\u305b\u3001\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30a4\u30d9\u30f3\u30c8\u306e\u53d6\u5f97\u30fb\u8ffd\u52a0\u30fb\u524a\u9664\u3092\u884c\u3044\u305f\u3044\u3002\u307e\u305f\u3001JavaScript\u3067\u65e5\u4ed8\u95a2\u9023\u306e\u51e6\u7406\u3092\u3059\u308b\u969b\u306b\u3001PHP\u3088\u308a\u3082\u4f55\u304b\u3068\u9762\u5012\u306a\u306e\u3067\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u5bfe\u5fdc\u3057\u305f\u3044\u3002\u4ee5\u4e0b\u306b\u5bfe\u5fdc\u65b9\u6cd5\u306e\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8ffd\u52a0<\/h2>\n<p>\u300cDay.js\u300d\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u826f\u3044\u3089\u3057\u3044\u3002\u4ee5\u4e0b\u30b9\u30af\u30ea\u30d7\u30c8ID\u3067\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">1ShsRhHc8tgPy5wGOzUvgEhOedJUQD53m-gd8lG2MOgs-dXC_aCZn9lFB<\/pre>\n<p>\u4ee5\u4e0b\u304c\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3002<\/p>\n<p><a href=\"https:\/\/day.js.org\/docs\/en\/parse\/now\" target=\"_blank\" rel=\"noopener\">https:\/\/day.js.org\/docs\/en\/parse\/now<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9<\/h2>\n<h3>\u30a4\u30d9\u30f3\u30c8\u306e\u53d6\u5f97<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">\/\/\u30a4\u30d9\u30f3\u30c8\u306e\u53d6\u5f97\r\nfunction getCalendar(){\r\n\r\n\t\/\/\u30e6\u30fc\u30b6\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30ab\u30ec\u30f3\u30c0\u30fc\u3092\u53d6\u5f97\r\n\tconst calendar = CalendarApp.getDefaultCalendar();\r\n\r\n\t\/\/\u4f55\u65e5\u5206\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u304b\r\n\tconst count = 30;\r\n\r\n\t\/\/\u958b\u59cb\u5e74\u6708\u65e5\r\n\tconst start = dayjs.dayjs().toDate();\r\n\r\n\t\/\/\u7d42\u4e86\u5e74\u6708\u65e5\r\n\tconst end = dayjs.dayjs().add(count, &#039;d&#039;).toDate();\r\n\r\n\t\/\/\u30ab\u30ec\u30f3\u30c0\u30fc\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u53d6\u5f97\r\n\tconst events = calendar.getEvents(start, end);\r\n\r\n\t\/\/1\u884c\u305a\u3064\u51fa\u529b\r\n\tfor(let event of events){\r\n\r\n\t\tlet tmp = &#039;&#039;;\r\n\r\n\t\t\/\/\u65e5\u4ed8\r\n\t\ttmp += &#039;\u65e5\u4ed8:&#039; + dayjs.dayjs(event.getStartTime()).format(&#039;YYYY-MM-DD&#039;);\r\n\r\n\t\t\/\/\u30bf\u30a4\u30c8\u30eb\r\n\t\ttmp += &#039; | \u30bf\u30a4\u30c8\u30eb:&#039; + event.getTitle();\r\n\r\n\t\t\/\/\u8a73\u7d30\r\n\t\ttmp += &#039; | \u8a73\u7d30:&#039; + event.getDescription();\r\n\r\n\t\tconsole.log(tmp);\r\n\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>\u30a4\u30d9\u30f3\u30c8\u306e\u8ffd\u52a0<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">\/\/\u30a4\u30d9\u30f3\u30c8\u306e\u8ffd\u52a0\r\nfunction setCalendar(){\r\n\r\n\t\/\/\u30e6\u30fc\u30b6\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30ab\u30ec\u30f3\u30c0\u30fc\u3092\u53d6\u5f97\r\n\tconst calendar = CalendarApp.getDefaultCalendar();\r\n\r\n\t\/\/\u30bf\u30a4\u30c8\u30eb\r\n\tconst title = &#039;\u30a4\u30d9\u30f3\u30c8\u30bf\u30a4\u30c8\u30eb&#039;;\r\n\r\n\t\/\/\u958b\u59cb\u65e5\u6642\r\n\tconst start = dayjs.dayjs().toDate();\r\n\r\n\t\/\/\u7d42\u4e86\u65e5\u6642\r\n\tconst end = dayjs.dayjs().toDate();\r\n\r\n\tconst option = {\r\n\t\t\/\/\u8a73\u7d30\r\n\t\tdescription : &quot;\u30a4\u30d9\u30f3\u30c8\u8a73\u7d30\\n\u6539\u884c\\n\u30a4\u30d9\u30f3\u30c8\u8a73\u7d30&quot;, \r\n\t};\r\n\r\n\t\/\/\u6642\u9593\u6307\u5b9a\u3067\u8ffd\u52a0\u3059\u308b\u5834\u5408\r\n\tcalendar.createEvent(title, start, end, option);\r\n\r\n\t\/\/\u7d42\u65e5\u6307\u5b9a\u3067\u8ffd\u52a0\u3059\u308b\u5834\u5408\r\n\tconst date = dayjs.dayjs().toDate();\r\n\tcalendar.createAllDayEvent(title, date, option);\r\n}<\/pre>\n<p>\u300c\u25cb\u6708\u25cb\u65e514\uff5e16\u6642\u300d\u306e\u3088\u3046\u306b\u6642\u9593\u6307\u5b9a\u3092\u3059\u308b\u5834\u5408\u306f\u300ccalendar.createEvent\u300d\u3092\u3001\u7d42\u65e5\u6307\u5b9a\u306e\u5834\u5408\u306f\u300ccalendar.createAllDayEvent\u300d\u3067\u30a4\u30d9\u30f3\u30c8\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u30a4\u30d9\u30f3\u30c8\u306e\u524a\u9664<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">\/\/\u30a4\u30d9\u30f3\u30c8\u306e\u524a\u9664\r\nfunction deleteCalendar(){\r\n\r\n\t\/\/\u30e6\u30fc\u30b6\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30ab\u30ec\u30f3\u30c0\u30fc\u3092\u53d6\u5f97\r\n\tconst calendar = CalendarApp.getDefaultCalendar();\r\n\r\n\t\/\/\u4f55\u65e5\u5206\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u304b\r\n\tconst count = 30;\r\n\r\n\t\/\/\u958b\u59cb\u5e74\u6708\u65e5\r\n\tconst start = dayjs.dayjs().toDate();\r\n\r\n\t\/\/\u7d42\u4e86\u5e74\u6708\u65e5\r\n\tconst end = dayjs.dayjs().add(count, &#039;d&#039;).toDate();\r\n\r\n\t\/\/\u30ab\u30ec\u30f3\u30c0\u30fc\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u53d6\u5f97\r\n\tconst events = calendar.getEvents(start, end);\r\n\r\n\t\/\/1\u884c\u305a\u3064\u51fa\u529b\r\n\tfor(let event of events){\r\n\r\n\t\tlet title = event.getTitle();\r\n\r\n\t\t\/\/\u30bf\u30a4\u30c8\u30eb\u306b\u300ctest\u300d\u3092\u542b\u3080\u5834\u5408\u306f\u524a\u9664\r\n\t\tif( title.indexOf(&#039;test&#039;) &gt;= 0 ){\r\n\t\t\tevent.deleteEvent();\r\n\t\t}\r\n\r\n\t}\r\n\r\n}<\/pre>\n<p>\u300cevent.deleteEvent\u300d\u95a2\u6570\u306b\u306f\u5f15\u6570\u304c\u6307\u5b9a\u3067\u304d\u306a\u3044\u6a21\u69d8\u3002\u306a\u306e\u3067\u300c\u30bf\u30a4\u30c8\u30eb\u304c\u25cb\u25cb\u306e\u5834\u5408\u300d\u3084\u300c\u30a4\u30d9\u30f3\u30c8\u30e9\u30d9\u30eb\u306e\u8272\u304c\u25cb\u25cb\u306e\u5834\u5408\u300d\u7b49\u3001\u6761\u4ef6\u5206\u5c90\u3067\u524a\u9664\u3059\u308b\u5f62\u306b\u306a\u308a\u305d\u3046\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>\u30ab\u30ec\u30f3\u30c0\u30fc\u3068\u306e\u9023\u643a\u3088\u308a\u3082\u65e5\u4ed8\u51e6\u7406\u3067\u3042\u3063\u305f\u308a\u3001\u65e5\u4ed8\u5f62\u5f0f\u306e\u6307\u5b9a\u304c\u975e\u5e38\u306b\u9762\u5012\u3060\u3063\u305f\u3002\u3053\u3053\u3089\u8fba\u306f\u3082\u3046\u3061\u3087\u3063\u3068\u6163\u308c\u3066\u3044\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u304b\u3082\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Apps Script\u306e\u52c9\u5f37\u3068\u3057\u3066Google\u30ab\u30ec\u30f3\u30c0\u30fc\u3068\u9023\u643a\u3055\u305b ... <\/p>\n","protected":false},"author":1,"featured_media":3294,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[72,70],"tags":[],"class_list":["post-3365","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-apps-script","category-google"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=3365"}],"version-history":[{"count":0,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3365\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/3294"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=3365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=3365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=3365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}