Class: Daru::Offsets::YearBegin
Overview
Create a year begin offset
Constant Summary
collapse
- FREQ =
'YB'.freeze
Instance Method Summary
collapse
#freq_string, #initialize
Methods inherited from DateOffset
#-@, #initialize
Instance Method Details
#+(date_time) ⇒ Object
334
335
336
337
|
# File 'lib/daru/date_time/offsets.rb', line 334
def + date_time
DateTime.new(date_time.year + @n, 1, 1,
date_time.hour,date_time.min, date_time.sec)
end
|
#-(date_time) ⇒ Object
339
340
341
342
343
344
345
346
|
# File 'lib/daru/date_time/offsets.rb', line 339
def - date_time
if on_offset?(date_time)
DateTime.new(date_time.year - @n, 1, 1,
date_time.hour,date_time.min, date_time.sec)
else
DateTime.new(date_time.year - (@n-1), 1, 1)
end
end
|
#on_offset?(date_time) ⇒ Boolean
348
349
350
|
# File 'lib/daru/date_time/offsets.rb', line 348
def on_offset? date_time
date_time.month == 1 && date_time.day == 1
end
|