module Martlet::CalendarHelpers
Public Instance Methods
calendar_date(date)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 9 def calendar_date(date) sprintf "%04d%02d%02d", date.year, date.month, date.day end
calendar_day(day)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 13 def calendar_day(day) case day.capitalize when 'Sunday' then 'SU' when 'Monday' then 'MO' when 'Tuesday' then 'TU' when 'Wednesday' then 'WE' when 'Thursday' then 'TH' when 'Friday' then 'FR' when 'Saturday' then 'SA' end end
calendar_days(days)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 25 def calendar_days(days) repeat_days = days.map { |day| calendar_day(day) } repeat_days.join(',') end
calendar_time(time)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 5 def calendar_time(time) sprintf "%02d%02d00", time.hour, time.min end
exclude_first_day?(meeting)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 36 def exclude_first_day?(meeting) !in_days?(meeting.start_date, meeting.days) end
in_days?(date, days)
click to toggle source
# File lib/martlet/calendar_helpers.rb, line 30 def in_days?(date, days) wday = date.wday wdays = days.map { |day| number_from_day(day) } wdays.include?(wday) end