Module: TimeOfDayAttr::Seconds

Defined in:
lib/time_of_day_attr/seconds.rb

Class Method Summary collapse

Class Method Details

.convert_to_time_of_day(value, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/time_of_day_attr/seconds.rb', line 3

def self.convert_to_time_of_day(value, options = {})
  return value unless value.respond_to?(:seconds)

  format = options[:format] || DEFAULT_FORMATS.first
  time_format = TimeFormat.translate_format(format)

  time_of_day = seconds_to_time_of_day(value, time_format)
  if options[:omit_minutes_at_full_hour]
    TimeOfDay.omit_minutes_at_full_hour(time_of_day)
  else
    time_of_day
  end
end