chore: refactor parseVAlarm
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
287a21da93
commit
0ef9b55536
|
@ -152,34 +152,39 @@ func ParseTaskFromVTODO(content string) (vTask *models.Task, err error) {
|
||||||
|
|
||||||
func parseVAlarm(vAlarm *ics.VAlarm, vTask *models.Task) *models.Task {
|
func parseVAlarm(vAlarm *ics.VAlarm, vTask *models.Task) *models.Task {
|
||||||
for _, property := range vAlarm.UnknownPropertiesIANAProperties() {
|
for _, property := range vAlarm.UnknownPropertiesIANAProperties() {
|
||||||
if property.IANAToken == "TRIGGER" {
|
if property.IANAToken != "TRIGGER" {
|
||||||
if contains(property.ICalParameters["VALUE"], "DATE-TIME") {
|
continue
|
||||||
// Example: TRIGGER;VALUE=DATE-TIME:20181201T011210Z
|
|
||||||
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
|
||||||
Reminder: caldavTimeToTimestamp(property.Value)})
|
|
||||||
} else {
|
|
||||||
if contains(property.ICalParameters["RELATED"], "END") {
|
|
||||||
// Example: TRIGGER;RELATED=END:-P2D
|
|
||||||
duration := utils.ParseISO8601Duration(property.Value)
|
|
||||||
if vTask.EndDate.IsZero() {
|
|
||||||
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
|
||||||
RelativePeriod: int64(duration.Seconds()),
|
|
||||||
RelativeTo: models.ReminderRelationDueDate})
|
|
||||||
} else {
|
|
||||||
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
|
||||||
RelativePeriod: int64(duration.Seconds()),
|
|
||||||
RelativeTo: models.ReminderRelationEndDate})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Example: TRIGGER;RELATED=START:-P2D
|
|
||||||
// Example: TRIGGER:-PT60M
|
|
||||||
duration := utils.ParseISO8601Duration(property.Value)
|
|
||||||
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
|
||||||
RelativePeriod: int64(duration.Seconds()),
|
|
||||||
RelativeTo: models.ReminderRelationStartDate})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if contains(property.ICalParameters["VALUE"], "DATE-TIME") {
|
||||||
|
// Example: TRIGGER;VALUE=DATE-TIME:20181201T011210Z
|
||||||
|
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
||||||
|
Reminder: caldavTimeToTimestamp(property.Value),
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
duration := utils.ParseISO8601Duration(property.Value)
|
||||||
|
|
||||||
|
if contains(property.ICalParameters["RELATED"], "END") {
|
||||||
|
// Example: TRIGGER;RELATED=END:-P2D
|
||||||
|
if vTask.EndDate.IsZero() {
|
||||||
|
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
||||||
|
RelativePeriod: int64(duration.Seconds()),
|
||||||
|
RelativeTo: models.ReminderRelationDueDate})
|
||||||
|
} else {
|
||||||
|
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
||||||
|
RelativePeriod: int64(duration.Seconds()),
|
||||||
|
RelativeTo: models.ReminderRelationEndDate})
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example: TRIGGER;RELATED=START:-P2D
|
||||||
|
// Example: TRIGGER:-PT60M
|
||||||
|
vTask.Reminders = append(vTask.Reminders, &models.TaskReminder{
|
||||||
|
RelativePeriod: int64(duration.Seconds()),
|
||||||
|
RelativeTo: models.ReminderRelationStartDate})
|
||||||
}
|
}
|
||||||
return vTask
|
return vTask
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user