google-apps-script - 如何在 Google Apps 脚本中获取日历活动的开始和结束时间?
问题描述
getStartTime()
andgetEndTime()
只返回日期。如何获取活动的开始和结束时间?
var allEvents = calendar.getEvents(new Date('June 3, 2020'), new Date('August 6, 2020'));
var startDateTime = allEvents[j].getStartTime();
var endDateTime = allEvents[j].getEndTime();
解决方案
startDateTime
and endDateTime
are Date objects, meaning you can apply all the relevant methods.
var allEvents = calendar.getEvents(new Date('June 3, 2020'), new Date('August 6, 2020'));
var startDateTime = allEvents[j].getStartTime();
var startDateTime24 = startDateTime.getHours() + ":" + startDateTime.getMinutes()
var endDateTime = allEvents[j].getEndTime();
var endDateTime24 = endDateTime.getHours() + ":" + endDateTime.getMinutes()
Now startDateTime24
and endDateTime24
contain the time of the start and end of the event respectively in the 24-hour notation in the form hh:mm.
Note in the code I assume that calendar
holds a reference to an instance of CalendarApp
.
推荐阅读
- python - argparse 可以将参数转发给其他 python 文件吗?
- mysql - IF/THEN 返回 Column 是否为 PrimaryKey
- react-native - 在 React Native 中的数组或对象内部时,i18n 无法正确翻译
- r - 带有 Flexdashboard 的 Plotly 和 DT 表
- python - 带有 DataLoader 和 3D 输入的小批量。(火炬)
- amazon-web-services - AWS ElasticSearch 不接受某些 CloudTrail 文档
- python - 在 Django Admin 中配置列的宽度
- java - 在 Tomcat JSP 页面中使用 JDK15 的 JEP 378 文本块
- javascript - 向阻止滚动的“touchmove”事件添加了非被动事件侦听器。考虑将事件处理程序标记为“被动”
- php - PHP file_get_contents 获取/发送图像到浏览器比直接链接到相同的图像慢得多