Skip to content

Commit

Permalink
refactor: align code formatting and comments in eventtime
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Aug 27, 2024
1 parent 45ea92a commit dee6411
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
43 changes: 21 additions & 22 deletions ical/eventtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,34 @@ func (et *EventTime) nextTime(now time.Time) (time.Time, error) {
return time.Time{}, err
}


// If it also has RDATE this also works properly
// If it also has RDATE this also works properly
if et.hasRRule() {
// time can be Zero
return s.After(now, false), nil
}
// time can be Zero
return s.After(now, false), nil
}

// Seems to be BUG in github.com/teambition/rrule-go.
// teambition does not consider the DTSTART when RDATE but no RRULE
if et.hasRDate() {
// According to the iCalendar specification (RFC 5545), DTSTART is a
// required property for VEVENT components
dtStart := s.GetDTStart()
// Seems to be BUG in github.com/teambition/rrule-go.
// teambition does not consider the DTSTART when RDATE but no RRULE
if et.hasRDate() {
// According to the iCalendar specification (RFC 5545), DTSTART is a
// required property for VEVENT components
dtStart := s.GetDTStart()

if dtStart.After(now) {
return dtStart, nil
}
if dtStart.After(now) {
return dtStart, nil
}

return s.After(now, false), nil
}
return s.After(now, false), nil
}

dtStart := s.GetDTStart()
dtStart := s.GetDTStart()

if dtStart.After(now) {
return dtStart, nil
}
if dtStart.After(now) {
return dtStart, nil
}

// expired
return time.Time{}, nil
// expired
return time.Time{}, nil
}

func (et *EventTime) joinLines() string {
Expand Down
5 changes: 2 additions & 3 deletions ical/eventtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ END:VEVENT`
et := newEventTime(event)
et.parse()

// After first
// After first
now := time.Date(2024, 10, 1, 0, 0, 0, 0, time.UTC)
nextTime, err := et.nextTime(now)
if err != nil {
Expand Down Expand Up @@ -503,7 +503,7 @@ END:VEVENT`
t.Errorf("nextTime() = %v; want %v", nextTime, expectedTime)
}

// now after RDATE
// now after RDATE

now = time.Date(2027, 4, 11, 0, 0, 0, 0, time.UTC)
nextTime, err = et.nextTime(now)
Expand All @@ -516,5 +516,4 @@ END:VEVENT`
t.Errorf("nextTime() = %v; want %v", nextTime, expectedTime)
}


}

0 comments on commit dee6411

Please sign in to comment.