Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pull-66-add-todo-journal-orphan'…
Browse files Browse the repository at this point in the history
… into pull-66-add-todo-journal

* origin/pull-66-add-todo-journal-orphan:
  Add changes for All Day Events to All Day Todos
  Add Comment and Category Properties to Components
  Fix Typos in a couple places
  Add Alarm, Timezone, and FreeBusy Property Methods
  Add Todo and Journal Property Methods

# Conflicts:
#	calendar.go
#	components.go
  • Loading branch information
arran4 committed Jan 8, 2024
2 parents 1a61754 + 4b2d6a1 commit a55aac2
Show file tree
Hide file tree
Showing 2 changed files with 458 additions and 206 deletions.
115 changes: 34 additions & 81 deletions calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,40 @@ const (
type ComponentProperty Property

const (
ComponentPropertyUniqueId = ComponentProperty(PropertyUid) // TEXT
ComponentPropertyDtstamp = ComponentProperty(PropertyDtstamp)
ComponentPropertyOrganizer = ComponentProperty(PropertyOrganizer)
ComponentPropertyAttendee = ComponentProperty(PropertyAttendee)
ComponentPropertyAttach = ComponentProperty(PropertyAttach)
ComponentPropertyDescription = ComponentProperty(PropertyDescription) // TEXT
ComponentPropertyCategories = ComponentProperty(PropertyCategories) // TEXT
ComponentPropertyClass = ComponentProperty(PropertyClass) // TEXT
ComponentPropertyColor = ComponentProperty(PropertyColor) // TEXT
ComponentPropertyCreated = ComponentProperty(PropertyCreated)
ComponentPropertySummary = ComponentProperty(PropertySummary) // TEXT
ComponentPropertyDtStart = ComponentProperty(PropertyDtstart)
ComponentPropertyDtEnd = ComponentProperty(PropertyDtend)
ComponentPropertyLocation = ComponentProperty(PropertyLocation) // TEXT
ComponentPropertyStatus = ComponentProperty(PropertyStatus) // TEXT
ComponentPropertyFreebusy = ComponentProperty(PropertyFreebusy)
ComponentPropertyLastModified = ComponentProperty(PropertyLastModified)
ComponentPropertyUrl = ComponentProperty(PropertyUrl)
ComponentPropertyGeo = ComponentProperty(PropertyGeo)
ComponentPropertyTransp = ComponentProperty(PropertyTransp)
ComponentPropertySequence = ComponentProperty(PropertySequence)
ComponentPropertyExdate = ComponentProperty(PropertyExdate)
ComponentPropertyExrule = ComponentProperty(PropertyExrule)
ComponentPropertyRdate = ComponentProperty(PropertyRdate)
ComponentPropertyRrule = ComponentProperty(PropertyRrule)
ComponentPropertyAction = ComponentProperty(PropertyAction)
ComponentPropertyTrigger = ComponentProperty(PropertyTrigger)
ComponentPropertyPriority = ComponentProperty(PropertyPriority)
ComponentPropertyUniqueId = ComponentProperty(PropertyUid) // TEXT
ComponentPropertyDtstamp = ComponentProperty(PropertyDtstamp)
ComponentPropertyOrganizer = ComponentProperty(PropertyOrganizer)
ComponentPropertyAttendee = ComponentProperty(PropertyAttendee)
ComponentPropertyAttach = ComponentProperty(PropertyAttach)
ComponentPropertyDescription = ComponentProperty(PropertyDescription) // TEXT
ComponentPropertyCategories = ComponentProperty(PropertyCategories) // TEXT
ComponentPropertyClass = ComponentProperty(PropertyClass) // TEXT
ComponentPropertyColor = ComponentProperty(PropertyColor) // TEXT
ComponentPropertyCreated = ComponentProperty(PropertyCreated)
ComponentPropertySummary = ComponentProperty(PropertySummary) // TEXT
ComponentPropertyDtStart = ComponentProperty(PropertyDtstart)
ComponentPropertyDtEnd = ComponentProperty(PropertyDtend)
ComponentPropertyLocation = ComponentProperty(PropertyLocation) // TEXT
ComponentPropertyStatus = ComponentProperty(PropertyStatus) // TEXT
ComponentPropertyFreebusy = ComponentProperty(PropertyFreebusy)
ComponentPropertyLastModified = ComponentProperty(PropertyLastModified)
ComponentPropertyUrl = ComponentProperty(PropertyUrl)
ComponentPropertyGeo = ComponentProperty(PropertyGeo)
ComponentPropertyTransp = ComponentProperty(PropertyTransp)
ComponentPropertySequence = ComponentProperty(PropertySequence)
ComponentPropertyExdate = ComponentProperty(PropertyExdate)
ComponentPropertyExrule = ComponentProperty(PropertyExrule)
ComponentPropertyRdate = ComponentProperty(PropertyRdate)
ComponentPropertyRrule = ComponentProperty(PropertyRrule)
ComponentPropertyAction = ComponentProperty(PropertyAction)
ComponentPropertyTrigger = ComponentProperty(PropertyTrigger)
ComponentPropertyPriority = ComponentProperty(PropertyPriority)
ComponentPropertyResources = ComponentProperty(PropertyResources)
ComponentPropertyCompleted = ComponentProperty(PropertyCompleted)
ComponentPropertyDue = ComponentProperty(PropertyDue)
ComponentPropertyPercentComplete = ComponentProperty(PropertyPercentComplete)
ComponentPropertyTzid = ComponentProperty(PropertyTzid)
ComponentPropertyComment = ComponentProperty(PropertyComment)
)

type Property string
Expand Down Expand Up @@ -405,59 +411,6 @@ func (calendar *Calendar) setProperty(property Property, value string, props ...
calendar.CalendarProperties = append(calendar.CalendarProperties, r)
}

func NewEvent(uniqueId string) *VEvent {
e := &VEvent{
ComponentBase{
Properties: []IANAProperty{
{
BaseProperty{
IANAToken: ToText(string(ComponentPropertyUniqueId)),
Value: uniqueId,
},
},
},
},
}
return e
}

func (calendar *Calendar) AddEvent(id string) *VEvent {
e := NewEvent(id)
calendar.Components = append(calendar.Components, e)
return e
}

func (calendar *Calendar) AddVEvent(e *VEvent) {
calendar.Components = append(calendar.Components, e)
}

func (calendar *Calendar) RemoveEvent(id string) {
for i := range calendar.Components {
switch event := calendar.Components[i].(type) {
case *VEvent:
if event.Id() == id {
if len(calendar.Components) > i+1 {
calendar.Components = append(calendar.Components[:i], calendar.Components[i+1:]...)
} else {
calendar.Components = calendar.Components[:i]
}
return
}
}
}
}

func (calendar *Calendar) Events() (r []*VEvent) {
r = []*VEvent{}
for i := range calendar.Components {
switch event := calendar.Components[i].(type) {
case *VEvent:
r = append(r, event)
}
}
return
}

func ParseCalendar(r io.Reader) (*Calendar, error) {
state := "begin"
c := &Calendar{}
Expand Down
Loading

0 comments on commit a55aac2

Please sign in to comment.