Method: Doing::WWID#get_interval

Defined in:
lib/doing/wwid/timers.rb,
lib/doing/wwid/timers.rb

#get_interval(item, formatted: true, record: true) ⇒ Object

Gets the interval between entry's start date and @done date

Parameters:

  • item (Item)

    The entry

  • formatted (Boolean) (defaults to: true)

    Return human readable time (default seconds)

  • record (Boolean) (defaults to: true)

    Add the interval to the total for each tag

Returns:

  • Interval in seconds, or [d, h, m] array if formatted is true. False if no end date or interval is 0



152
153
154
155
156
157
158
159
160
161
162
# File 'lib/doing/wwid/timers.rb', line 152

def get_interval(item, formatted: true, record: true)
  if item.interval
    seconds = item.interval
    record_tag_times(item, seconds) if record
    return seconds.positive? ? seconds : false unless formatted

    return seconds.positive? ? seconds.time_string(format: :clock) : false
  end

  false
end