Module: Redmine::CoreExtensions::Date::Calculations

Included in:
Date
Defined in:
lib/redmine/core_ext/date/calculations.rb

Overview

Custom date calculations

Instance Method Summary collapse

Instance Method Details

#months_ago(date = self.class.today) ⇒ Object

Returns difference with specified date in months



24
25
26
# File 'lib/redmine/core_ext/date/calculations.rb', line 24

def months_ago(date = self.class.today)
  (date.year - self.year)*12 + (date.month - self.month)
end

#weeks_ago(date = self.class.today) ⇒ Object

Returns difference with specified date in weeks



29
30
31
# File 'lib/redmine/core_ext/date/calculations.rb', line 29

def weeks_ago(date = self.class.today)
  (date.year - self.year)*52 + (date.cweek - self.cweek)
end