Class: DaruLite::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
301
302
303
304
305
306
307
308
309
310
311
|
# File 'lib/daru_lite/date_time/offsets.rb', line 301
def +(other)
@n.times do
other >>= 1 if on_offset?(other)
days_in_month = DaruLite::MONTH_DAYS[other.month]
days_in_month += 1 if other.leap? && other.month == 2
other += (days_in_month - other.day)
end
other
end
|
313
314
315
316
317
318
319
320
321
322
323
|
# File 'lib/daru_lite/date_time/offsets.rb', line 313
def -(other)
@n.times do
other <<= 1
days_in_month = DaruLite::MONTH_DAYS[other.month]
days_in_month += 1 if other.leap? && other.month == 2
other += (days_in_month - other.day)
end
other
end
|
#on_offset?(date_time) ⇒ Boolean
325
326
327
|
# File 'lib/daru_lite/date_time/offsets.rb', line 325
def on_offset?(date_time)
(date_time + 1).day == 1
end
|