Utility methods common to some expressions
# File lib/runt/temporalexpression.rb, line 247 def days_left_in_month(date) return max_day_of_month(date) - date.day end
# File lib/runt/temporalexpression.rb, line 251 def max_day_of_month(date) # Contributed by Justin Cunningham who took it verbatim from the Rails # ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods module # days_in_month method. month = date.month year = date.year if month == 2 !year.nil? && (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) ? 29 : 28 elsif month <= 7 month % 2 == 0 ? 30 : 31 else month % 2 == 0 ? 31 : 30 end end
# File lib/runt/temporalexpression.rb, line 281 def week_from_end_matches?(index,date) n = days_left_in_month(date) + 1 week_in_month(n)==index.abs end
# File lib/runt/temporalexpression.rb, line 277 def week_from_start_matches?(index,date) week_in_month(date.day)==index end
Generated with the Darkfish Rdoc Generator 2.