如何弥补将来ICS文件日历下载的日光节省时间
我有各个项目的截止日期清单。每3个月一次,我将接下来的3个月的截止日期作为ICS文件,并将其添加到我的日历中。因为我每3个月只下载一次,所以我在夏令时(DST)遇到了一个问题。这是一个问题的示例:
- 一月,我下载了2月,3月和4月的即将到来的截止日期,将时间定为上午9:00的日期。
- 3月13日(DST的开始)到来,截止日期开始出现为8:00 AM,因为当我下载它们时,它不是DST,所以当我们“向前奔向”时,过去9:00 AM现在是8 :00 am,文件没有补偿。
我很难确定解决此问题的最佳方法在哪里:
- 在ICS文件本身的配置中。我想,如果有一个地方可以做到这一点,那就在这里。我已经搜查了ICS文件的文档,但尚未找到将来可以自动补偿DST的内容。
- 在前端的JavaScript中。我知道JavaScript可以选择将TimeZone设置为一个区域(“ America/New_york”),而不是时区,这有助于自动补偿DST ,但是我无法将该功能在以后的日期上工作,因为它只引用了当前时间。
- 在后端的PostgreSQL中。我在时区域上尝试了各种版本的
,毫无用处。我遇到了在JavaScript中遇到的相同问题:它设置了指定时区的时间,而没有考虑到将来是否会受到DST的影响。
更新发布以包含更多信息
截止日期信息(project_name
和dure_date
)是从PostgreSQL数据库中提取的。截止日期以这样的日期值存储:05-MAR-22
。
为了增加时间,我采用了两种方法:
- 在PostgreSQL中添加时间:
select ('06-JUN-2022'::date + time '9:00') at time zone 'America/New_York'
- 添加这样的JavaScript中的时间:
deadline.DUE_DATE = deadline.DUE_DATE.split("T"[0] += " 09:00:00";
但是,这两种方法都没有帮助我解决了时区问题。
JavaScript微服务设置以下字段:
BEGIN:VEVENT
UID:[ UID ]
SUMMARY:[ PROJECT_NAME ]
DTSTAMP:[ DTSTAMP ]
DTSTART:[ DTSTART ]
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:[ TRIGGER ]
END:VALARM
DURATION:PT
END:VEVENT
似乎缺少配置时区的一些重要细节。
I have a list of deadlines for various projects. Once every 3 months, I download the next 3 months' worth of deadlines as ICS files and add them to my calendar. Because I only download them once every 3 months, I am experiencing an issue with regards to daylight saving time (DST). Here is an example of the problem:
- In January, I download the upcoming deadlines for February, March, and April, setting the time as 9:00 AM on their respective dates.
- Come March 13th (the start of DST), the deadlines start to appear as 8:00 AM because when I downloaded them, it was not DST, so when we "sprung forward," what used to be 9:00 AM is now 8:00 AM, and the files are not compensating for that.
I have had trouble determining where the best way to solve this problem would be:
- In the configuration of the ICS file itself. I imagine that if there was a place to do this, it would be here. I have scoured the documentation of ICS files and have yet to find something that would auto-compensate for DST in the future.
- In JavaScript on the front-end. I know that JavaScript has the option of setting the timezone to a region ("America/New_York") instead of a time zone, which helps it auto-compensate for DST, but I have not been able to get that feature to work on a date in the future, as it only references the current time.
- In PostgreSQL on the back-end. I have tried various versions of
AT TIME ZONE
to no avail. I encounter the same problem I did in JavaScript: It sets the time in the specified time zone without taking into account whether or not the date would be affected by DST in the future.
Update to Post to Include More Information
The deadline information (PROJECT_NAME
and DUE_DATE
) is extracted from a PostgreSQL database. The due date is stored as a DATE value like this: 05-MAR-22
.
To add the time, I have taken two approaches:
- Adding the time in PostgreSQL like this:
select ('06-JUN-2022'::date + time '9:00') at time zone 'America/New_York'
- Adding the time in JavaScript like this:
deadline.DUE_DATE = deadline.DUE_DATE.split("T"[0] += " 09:00:00";
But neither method has helped me solve the timezone issue.
The JavaScript microservice sets the following fields:
BEGIN:VEVENT
UID:[ UID ]
SUMMARY:[ PROJECT_NAME ]
DTSTAMP:[ DTSTAMP ]
DTSTART:[ DTSTART ]
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:[ TRIGGER ]
END:VALARM
DURATION:PT
END:VEVENT
which seems to be missing a few important details for configuring the timezone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
You have the option of embedding time zone information in the ICS file by utilizing the tzid参数和 vtimezone组件 ICS文件。 Vtimezone组件需要将有关DST规则的信息添加到文件中,并且每个唯一的TZID都必须具有相应的Vtimezone组件。您可以使用 tzurl.org ,该已经为每个时区域生成了VTimeZone定义。有关如何执行此操作的更多信息,您可以参考这些相关问题:
我缺乏对Microsoft Outlook和Apple日历的特定实现详细信息的了解,但是我很确定他们会从ICS文件中考虑此类相关信息。
查看如何使用JavaScript生成ICS文件。听起来,时区被设置为日光前的时区,这将在储蓄日光后查看事件时会引起问题。根据 ICS规范:
这也可能指出可能错误地设置了时区,因为如果未定义“ tzid”/“ vtimezone”组件,则应将事件视为“浮动”,或“相同的小时,分钟和第二个”价值不管目前正在观察到哪个时区。”
You have the option of embedding time zone information in the ICS file by utilizing the TZID parameter and VTIMEZONE component of ICS files. The VTIMEZONE component requires adding information about DST rules to the file, and each unique TZID must have a corresponding VTIMEZONE component. You can use tzurl.org which has generated VTIMEZONE definitions for every time zone. For more information about how to do this, you can refer to these related questions:
I am lacking some knowledge of the specific implementation details of Microsoft Outlook and Apple calendar, but I'm pretty sure that they would take such relevant information from the ICS file into account.
Look at how you are generating the ICS files with Javascript. It sounds like the timezone is being set to the pre-daylight-savings timezone, which will cause problems when viewing the event after the daylight savings shift. According to the ics specification:
This may also point to the possibility that the timezone is being set incorrectly, because if the "TZID"/"VTIMEZONE" components were not defined, the events should be regarded as "floating", or "the same hour, minute, and second value regardless of which time zone is currently being observed."