Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/rails_com/core/date.rb
Instance Method Summary collapse
-
#after(other) ⇒ Object
Chinese custom after date ‘2018-01-01’.to_date.after(2.month) => ‘2018-02-31’ ‘2018-01-31’.to_date.after(1.month) => ‘2018-03-02’.
Instance Method Details
#after(other) ⇒ Object
Chinese custom after date
'2018-01-01'.to_date.after(2.month) => '2018-02-31'
'2018-01-31'.to_date.after(1.month) => '2018-03-02'
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails_com/core/date.rb', line 6 def after(other) if ActiveSupport::Duration === other if other.parts.keys == [:months] date = self + other if date.day == self.day r = date - 1.day else r = date + (self.day - date.day - 1).days end r else self + other end else self + other end end |