golang-ical
golang-ical copied to clipboard
fix: omit zone in "AllDay" event helpers
For a date-only event (i.e., an event that lasts for the full day) the iCalendar specification indicates that the value for DTSTART / DTEND should be a DATE
https://icalendar.org/iCalendar-RFC-5545/3-6-1-event-component.html
The "VEVENT" is also the calendar component used to specify an anniversary or daily reminder within a calendar. These events have a DATE value type for the "DTSTART" property instead of the default value type of DATE-TIME. If such a "VEVENT" has a "DTEND" property, it MUST be specified as a DATE value also
The DATE format (https://icalendar.org/iCalendar-RFC-5545/3-3-4-date.html) should omit both time and zone/location elements and additionally notes that "The "TZID" property parameter MUST NOT be applied to DATE properties"
As per the specification, this PR also adds an explicit "VALUE=DATE" parameter when the AllDay helpers were called, to indicate that the property's default value type has been overridden and the VEVENT is intended to be an all-day event https://icalendar.org/iCalendar-RFC-5545/3-2-20-value-data-types.html
Finally the SetDuration call has been updated to preserve the "AllDay" characteristics if the existing start or end has been specified in DATE format, which is also a requirement of the spec.
Contributes-to: #55
I knocked up this PR whilst reading the spec and debugging why using the all day helpers wasn't producing an all day event in my generated .ics files. After finding the repo to submit the PR I spotted #55 and the abandoned PR #61, so this sort of supersedes that
It seems #69 was raised and merged 2 days ago which resurrected #61 but doesn't fixup SetDuration 😔
@jackhopner Can you verify that this change fixes your problem too?
@dnwe So sorry. I'm hoping a couple more months I will have time to put more diligence into this.
Yes it will do, it's essentially the same fix for that area. I've rebased the changes on top of latest master so it includes the additional tests and the fix for SetDuration