Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATE-TIME property formatting #75

Closed
jparise opened this issue Nov 6, 2012 · 3 comments
Closed

DATE-TIME property formatting #75

jparise opened this issue Nov 6, 2012 · 3 comments

Comments

@jparise
Copy link

jparise commented Nov 6, 2012

I'm not clear on why vDatetime properties (such as DTSTART) use the VALUE=DATE-TIME: syntax:

DTSTART;TZID=Europe/Vienna;VALUE=DATE-TIME:20101010T100000

RFC 5545 Section 3.3.5 describes a simpler (and more commonly used?) Date-Time format:

   DTSTART:19970714T133000                   ; Local time
   DTSTART:19970714T173000Z                  ; UTC time
   DTSTART;TZID=America/New_York:19970714T133000
                                             ; Local time and time
                                             ; zone reference

Mac OS X's Calendar.app doesn't appear to like the former but will accept the latter.

@regebro
Copy link
Contributor

regebro commented Nov 6, 2012

That's a bug in Calendar.app, in that case. VALUE=DATE-TIME just specifies what type the value has, and it can be DATE or DATE-TIME. DATE-TIME is default though, so it doesn't need to be specified, but that Calendar.app doesn't like it being specified is definitely a bug.

I guess logic could be added to skip VALUE= when it is DATE-TIME, though.

@jparise
Copy link
Author

jparise commented Nov 6, 2012

This was my mistake. There was a differently problem (caused by my code) that was producing bad DATE-TIME values.

But that aside, it does seem like a nice improvement to skip VALUE= when it's not necessary.

@jparise jparise closed this as completed Nov 6, 2012
Hagb added a commit to Hagb/cli_cqu that referenced this issue Aug 4, 2020
虽然同时带时区(TZID)和类型(VALUE)也符合标准,但是有一些日历软件对这种写法不支持(它们的锅)……
见 collective/icalendar#75
Hagb added a commit to Hagb/cli_cqu that referenced this issue Sep 2, 2020
同时带时区(TZID)和类型(VALUE)也符合 RFC 5545,有一些日历软件对这种写法不支持。
见 collective/icalendar#75
@Hagb
Copy link

Hagb commented Feb 15, 2021

I use this workaround

from icalendar import vDDDTypes
from datetime import datetime
def add_datetime(component, name: str, time: datetime):
    vdatetime: vDDDTypes = vDDDTypes(time)
    if 'VALUE' in vdatetime.params and 'TZID' in vdatetime.params:
        vdatetime.params.pop('VALUE')
    component.add(name, vdatetime)

...
from icalendar import Event
from datetime import timedelta, timezone
tz = datetime(2021,1,1,tzinfo=tz)
event = Event()
add_datetime(event, 'DTEND', datetime(2021,1,2,3,4,5,tzinfo=timezone(timedelta(hours=8), "Asia/Shanghai")))
print(event.to_ical().decode())
BEGIN:VEVENT
DTEND;TZID=Asia/Shanghai:20210102T030405
END:VEVENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants