Module: DateUtil

Included in:
MetricsGeneratorCsv
Defined in:
lib/codespicuous/dateutil.rb

Instance Method Summary collapse

Instance Method Details

#begin_of_week(date) ⇒ Object



4
5
6
# File 'lib/codespicuous/dateutil.rb', line 4

def begin_of_week(date)
  date - (date.cwday-1)
end

#for_each_week(start_date, end_date) ⇒ Object



12
13
14
15
16
# File 'lib/codespicuous/dateutil.rb', line 12

def for_each_week(start_date, end_date)
  (begin_of_week(start_date)..begin_of_week(end_date)).step(7) { |week|
    yield week
  }
end

#string_date(date) ⇒ Object



8
9
10
# File 'lib/codespicuous/dateutil.rb', line 8

def string_date(date)
  date.strftime("%Y-%m-%d")
end