Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/hosemonkey/ext/date.rb

Instance Method Summary collapse

Instance Method Details

#advance(options) ⇒ Object

From active support



3
4
5
6
7
8
9
10
11
# File 'lib/hosemonkey/ext/date.rb', line 3

def advance(options)
  options = options.dup
  d = self
  d = d >> options.delete(:years) * 12 if options[:years]
  d = d >> options.delete(:months)     if options[:months]
  d = d +  options.delete(:weeks) * 7  if options[:weeks]
  d = d +  options.delete(:days)       if options[:days]
  d
end

#change(options) ⇒ Object

From active support



14
15
16
17
18
19
20
# File 'lib/hosemonkey/ext/date.rb', line 14

def change(options)
  ::Date.new(
    options[:year]  || self.year,
    options[:month] || self.month,
    options[:day]   || self.day
  )
end