【问题标题】:How can I make Plone display events during DST with the correct time?如何在 DST 期间以正确的时间制作 Plone 显示事件?
【发布时间】:2011-09-09 14:34:47
【问题描述】:

我正在编写一个 Plone 产品,它采用 iCalendar,将其拉入并创建 Plone Event 类型。我已经让这一切正常工作了,除了在一年的一半日期里,时间戳相差一个小时。

我的 iCalendar 提要将这些作为 UTC 时间戳传递:

DTSTART;VALUE=DATE:20110812T130000Z 应该是 America/New_York 时区的上午 9 点 DTEND;VALUE=DATE:20110812T160000Z 应该是 America/New_York 时区的中午 12 点

那些工作正常。这些不:

DTSTART;VALUE=DATE:20111225T175525Z 应该是下午 1:55,但它显示为下午 12:55 DTEND;VALUE=DATE:20111225T215525Z 应该是下午 5:55,但它显示为下午 4:55

从生成 iCalendar 提要的数据库到 iCalendar 生成器,再到 Zope 中存储的实际值,一切都是正确的。但是 Plone 在事件详情页面上显示不正确的本地时间。

我已经尝试在我的构建中设置“TZ America/New_York”,我已经尝试在 Zope 服务器上设置系统时钟,以查看转换是否会在“我们返回 EST 之后”神奇地发生。没有运气。

这里有几个例子可以说明问题:

正确显示事件,发生在 EDT:

 BEGIN:VEVENT
DESCRIPTION:Flyer Fridays give you the opportunity to hear from professors
  in Communication Sciences & Disorders\, Education\, Management\, Nursing\
 , Physical Therapy\, Occupational Therapy or Visual & Performing Arts.  \n
 \nFaculty sessions begin at 9:15am (PLEASE CHOOSE ONE)\, followed by a 10a
 m campus tour and an 11am Freshmen information session.  After the day's e
 vents\, you're invited to join the Admissions staff for lunch.
DTEND;VALUE=DATE:20110812T160000Z
DTSTART;VALUE=DATE:20110812T130000Z
LOCATION:Nazareth College
SUMMARY:Flyer Friday - Management Info Session
UID:ug-flyerfriday-164
END:VEVENT

还有,它是如何存储在 Zope 中的:

>>> app.Plone.events['ug-flyerfriday-164'].startDate
DateTime('2011/08/12 13:00:00 GMT+0')

错误显示的事件,发生在 EST:

BEGIN:VEVENT
DESCRIPTION:Fun with TZINFO Flyer Fridays give you the opportunity to hear
  from professors in Communication Sciences & Disorders\, Education\, Manag
 ement\, Nursing\, Physical Therapy\, Occupational Therapy or Visual & Perf
 orming Arts.  \n\nFaculty sessions begin at 9:15am (PLEASE CHOOSE ONE)\, f
 ollowed by a 10am campus tour and an 11am Freshmen information session.  A
 fter the day's events\, you're invited to join the Admissions staff for lu
 nch.
DTEND;VALUE=DATE:20111225T215525Z
DTSTART;VALUE=DATE:20111225T175525Z
LOCATION:Nazareth College
SUMMARY:Flyer Friday - Timezone Info Session
UID:ug-flyerfriday-172
END:VEVENT

您可以看到它以 UTC 存储在 Zope 中,所以问题仅在于它的显示方式:

>>> app.Plone.events['ug-flyerfriday-172'].startDate
DateTime('2011/12/25 17:55:25 GMT+0')

【问题讨论】:

  • 我不明白当前行为有什么问题。 EST 是 GMT-5,因此 DST 无效的日期应显示为比存储的 GMT 值早 5 小时,对吧?
  • @David Glick 你是完全正确的。我已经盯着这个太久了。 :/ 问题出在 iCalendar 生产者身上。

标签: python plone icalendar zope dst


【解决方案1】:

试试Time Zone Converter

您正在尝试夏令时。 当您更改日期时会出现这种情况。

检查一个所谓的错误日期:

DTSTART;VALUE=DATE:20111225T175525Z should be 1:55pm, but it's showing as 12:55pm 并阅读图例:

夏令时无效 在格林威治标准时间的这个日期/时间

节省时间对此有效 美国/纽约的日期/时间

然后检查一个没有问题的日期:

DTSTART;VALUE=DATE:20110812T130000Z should be 9am in the America/New_York timezone 带有这个图例:

夏令时无效 在格林威治标准时间的这个日期/时间

节省时间对此有影响 美国/纽约的日期/时间

您可以在此处查看 America/New_York 时区的 Dailyght Saving Time 详细信息: http://www.timezoneconverter.com/cgi-bin/zoneinfo.tzc?s=default&tz=America/New_York

【讨论】:

    猜你喜欢
    • 2021-02-15
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 2012-01-06
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 1970-01-01
    相关资源
    最近更新 更多