Last active
February 1, 2019 10:56
-
-
Save Loriowar/5532450d7e2d505cf63d8802b6c50974 to your computer and use it in GitHub Desktop.
Horrible Rails Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 5.0.2 | |
# Ruby 2.4.0p0 | |
> Date.current | |
=> Fri, 01 Feb 2019 | |
> date = 1.day.ago | |
=> Thu, 31 Jan 2019 10:13:59 UTC +00:00 | |
> date + 1.month | |
=> Thu, 28 Feb 2019 10:13:59 UTC +00:00 | |
> date + 2.months | |
=> Sun, 31 Mar 2019 10:13:59 UTC +00:00 | |
date + 1.month + 1.month | |
=> Thu, 28 Mar 2019 10:13:59 UTC +00:00 | |
> 2.months == 1.month + 1.month | |
=> true | |
> end_of_january = 1.day.ago | |
=> Thu, 31 Jan 2019 09:54:54 UTC +00:00 | |
> end_of_january + 2.months | |
=> Sun, 31 Mar 2019 09:54:54 UTC +00:00 | |
> end_of_january + (1.month + 1.month) | |
=> Thu, 28 Mar 2019 09:54:54 UTC +00:00 | |
> end_of_january + (1.month * 2) | |
=> Mon, 01 Apr 2019 09:54:54 UTC +00:00 | |
> 2.months == (1.month * 2) | |
=> true | |
> (1.month + 1.month) == (1.month * 2) | |
=> true | |
> (1.month * 2).class | |
=> Integer | |
> (2.month).class | |
=> ActiveSupport::Duration | |
> 1.month == 30.days | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment