class Date
Public Class Methods
build_date_array(start_date, end_date)
click to toggle source
# File lib/creative_rails_utilities/date.rb, line 4 def self.build_date_array(start_date, end_date) start_date = start_date.to_date end_date = end_date.to_date raise_start_date_before_end_date if (start_date > end_date) date_array = [] processable_date = start_date.dup while processable_date <= end_date date_array << processable_date processable_date = processable_date.tomorrow end date_array end
range(start, _end)
click to toggle source
# File lib/creative_rails_utilities/date.rb, line 20 def self.range(start, _end) start.to_date.beginning_of_day.._end.to_date.end_of_day end
Public Instance Methods
array_with_pre_churn_limit(count_of_additional_days)
click to toggle source
# File lib/creative_rails_utilities/date.rb, line 38 def array_with_pre_churn_limit(count_of_additional_days) explicit_limit_date = (self + count_of_additional_days.days) now = Time.zone.now.to_date cutoff_date = (explicit_limit_date > now ? now.yesterday : explicit_limit_date) return Date.build_date_array(self, cutoff_date) end
build_date_array(date)
click to toggle source
# File lib/creative_rails_utilities/date.rb, line 24 def build_date_array(date) date = date.to_date if self < date start_date = self end_date = date else start_date = date end_date = self end return Date.build_date_array(start_date, end_date) end