Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require "active_support/all"
now = Date.current
# => Thu, 05 Sep 2013
now - 2.months - 5.days + 2.months + 5.days == now
# => false
now - 2.months - 5.days + 5.days + 2.months == now
# => true
@PaulOstazeski

This comment has been minimized.

Copy link

PaulOstazeski commented Sep 6, 2013

require "active_support/all"                                                   
# => true
a,b = 2.times.map { Date.current }
# => [Thu, 05 Sep 2013, Thu, 05 Sep 2013]
a,b = a - 2.months, b - 2.months
# => [Fri, 05 Jul 2013, Fri, 05 Jul 2013]
a,b = a - 5.days, b - 5.days
# => [Sun, 30 Jun 2013, Sun, 30 Jun 2013]
a,b = a + 2.months, b + 5.days
# => [Fri, 30 Aug 2013, Fri, 05 Jul 2013]
a,b = a + 5.days, b + 2.months
# => [Wed, 04 Sep 2013, Thu, 05 Sep 2013]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.