Method: Vpim::Icalendar::Vevent#duration

Defined in:
lib/vpim/vevent.rb

#durationObject

The duration in seconds of a Event, Todo, or Vfreebusy component, or for Alarms, the delay period prior to repeating the alarm. The duration is calculated from the DTEND and DTBEGIN fields if the DURATION field is not present. Durations of zero seconds are possible.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/vpim/vevent.rb', line 121

def duration
  dur = @properties.field 'DURATION'
  dte = @properties.field 'DTEND'
  if !dur
    return nil unless dte

    b = dtstart
    e = dtend

    return (e - b).to_i
  end

  Icalendar.decode_duration(dur.value_raw)
end