Class: Daru::Offsets::Year

Inherits:
Tick show all
Defined in:
lib/daru/date_time/offsets.rb

Overview

Create a years offset

Examples:

Create a Year offset

offset = Daru::Offsets::Year.new(2)
offset + DateTime.new(2012,5,1,4,3)
#=> #<DateTime: 2014-05-01T04:03:00+00:00 ((2456779j,14580s,0n),+0s,2299161j)>

Constant Summary collapse

FREQ =
'YEAR'.freeze

Instance Method Summary collapse

Methods inherited from Tick

#initialize

Methods inherited from DateOffsetType

#freq_string, #initialize

Methods inherited from DateOffset

#-@, #initialize

Constructor Details

This class inherits a constructor from Daru::Offsets::Tick

Instance Method Details

#+(date_time) ⇒ Object



202
203
204
# File 'lib/daru/date_time/offsets.rb', line 202

def + date_time
  date_time >> @n*12
end

#-(date_time) ⇒ Object



206
207
208
# File 'lib/daru/date_time/offsets.rb', line 206

def - date_time
  date_time << @n*12
end