Module: NexusCore::ReportUtils::PeriodDefinition

Included in:
NexusCore::ReportUtils
Defined in:
lib/nexus_core/report_utils.rb

Instance Method Summary collapse

Instance Method Details

#full_weeks_in_period(start, till) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/nexus_core/report_utils.rb', line 35

def full_weeks_in_period(start, till)
  start = Date.today.last_week.beginning_of_week if start.blank?
  till = Date.today.last_week.end_of_week if till.blank?
  start = [Date.today.last_week.beginning_of_week, start.beginning_of_week].min
  till = [Date.today.last_week.end_of_week, till.end_of_week].min
  [start, till].sort {|a,b| a <=> b}
end

#last_month_periodObject



31
32
33
# File 'lib/nexus_core/report_utils.rb', line 31

def last_month_period
  full_weeks_in_period(Date.today.last_month, Date.today)
end

#last_week_periodObject



27
28
29
# File 'lib/nexus_core/report_utils.rb', line 27

def last_week_period
  full_weeks_in_period(Date.today.last_week, Date.today)
end