Module: Calagator::TimeRangeHelper

Extended by:
TimeRangeHelper
Included in:
ApplicationHelper, EventsHelper, TimeRangeHelper
Defined in:
app/helpers/calagator/time_range_helper.rb

Defined Under Namespace

Classes: TimePart, TimePartRenderer, TimeRange

Instance Method Summary collapse

Instance Method Details

#normalize_time(start_time, end_time = nil, format: :hcal, context: nil) ⇒ Object

Initialize with a single DateTime, a pair of DateTimes, or an object that responds_to start_time and end_time, and two options By default (unless :format => :text) include <abbr> tags for hCalendar, if a :context date is provided, omit unnecessary date parts.



11
12
13
14
15
16
17
# File 'app/helpers/calagator/time_range_helper.rb', line 11

def normalize_time(start_time, end_time = nil, format: :hcal, context: nil)
  if end_time.nil? && start_time.respond_to?(:start_time)
    end_time = start_time.end_time
    start_time = start_time.start_time
  end
  TimeRange.new(start_time, end_time, format, context).to_s.html_safe
end