Class: Daru::Offsets::MonthEnd
Overview
Create a month end offset
Constant Summary
collapse
- FREQ =
'ME'.freeze
Instance Method Summary
collapse
#freq_string, #initialize
Methods inherited from DateOffset
#-@, #initialize
Instance Method Details
#+(date_time) ⇒ Object
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/daru/date_time/offsets.rb', line 295
def + date_time
@n.times do
date_time = date_time >> 1 if on_offset?(date_time)
days_in_month = Daru::MONTH_DAYS[date_time.month]
days_in_month += 1 if date_time.leap? && date_time.month == 2
date_time += (days_in_month - date_time.day)
end
date_time
end
|
#-(date_time) ⇒ Object
307
308
309
310
311
312
313
314
315
316
317
|
# File 'lib/daru/date_time/offsets.rb', line 307
def - date_time
@n.times do
date_time = date_time << 1
days_in_month = Daru::MONTH_DAYS[date_time.month]
days_in_month += 1 if date_time.leap? && date_time.month == 2
date_time += (days_in_month - date_time.day)
end
date_time
end
|
#on_offset?(date_time) ⇒ Boolean
319
320
321
|
# File 'lib/daru/date_time/offsets.rb', line 319
def on_offset? date_time
(date_time + 1).day == 1
end
|