module YearArray::TimeHelpers::ClassMethods

Public Instance Methods

hours_between(t1, t2) click to toggle source
# File lib/year_array/time_helpers.rb, line 16
def hours_between(t1, t2)
  ((t2-t1)/3600).to_i
end
hours_in_day(year, month, day) click to toggle source
# File lib/year_array/time_helpers.rb, line 12
def hours_in_day(year, month, day)
  hours_in_interval(:day, year, month, day)
end
hours_in_month(year, month) click to toggle source
# File lib/year_array/time_helpers.rb, line 8
def hours_in_month(year, month)
  hours_in_interval(:month, year, month)
end
hours_in_year(year) click to toggle source
# File lib/year_array/time_helpers.rb, line 4
def hours_in_year(year)
  hours_in_interval(:year, year)
end

Private Instance Methods

hours_in_interval(interval, year, month=1, day=1) click to toggle source
# File lib/year_array/time_helpers.rb, line 22
def hours_in_interval(interval, year, month=1, day=1)
  t1 = Time.new(year, month, day)
  t2 = t1+1.send(interval)
  hours_between(t1, t2)
end