Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

calendar - Single day all day appointments in .ics files

I'm creating an ics file using ASP.NET for importing holiday into Outlook 2007 and trying to set the all-day-event flag. This works fine on multi-day holidays, but for single days, it doesn't seem to be registering, I just get a 'singularity holiday' booked from midnight to midnight.

According to MSDN, setting the start and end times to 00:00 should be enough to do this. I've also tried using the X-MICROSOFT-CDO-ALLDAYEVENT and X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT flags, but they don't seem to have any effect.

Can anyone see where I'm going wrong? I've included sample ouput below.

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
DESCRIPTION:HOLIDAY

DTEND;VALUE=DATE:20090727
DTSTAMP:20091111T000000Z
DTSTART;VALUE=DATE:20090727
LAST-MODIFIED:20091111T000000Z
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-gb:HOLIDAY
TRANSP:OPAQUE
X-ALT-DESC;FMTTYPE=text/html:HOLIDAY
X-MICROSOFT-CDO-BUSYSTATUS:OOF
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-ALLOWEXTERNCHECK:TRUE
X-MS-OLK-CONFTYPE:0
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE
END:VEVENT
END:VCALENDAR
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@IceCool is right -- simply omitting the DTEND is not enough...it will depend on the data type of DTSTART whether that works.

The spec says that if DTSTART has a DATE data type, and there is no DTEND then the event finishes at the end of the day that it starts. But if DTSTART has a full DATE-TIME data type, and there is no DTEND then it finishes at the same time that it starts.

It's in section 3.6.1 of RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#page-54):

For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE value type but no "DTEND" nor "DURATION" property, the event's duration is taken to be one day. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME value type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.

So, the upshot is, to get an all day event, this is not enough:

DTSTART:20100101T000000

It doesn't work because the data type is DATE-TIME, and so the end of the event is the same as the start. To make an all day event you either need to add an explicit DTEND (also of type DATE-TIME):

DTSTART:20100101T000000
DTEND:20100102T000000

or use the DATE data type, and then there's no need for a DTEND:

DTSTART;VALUE=DATE:20100101

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...