mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Advance The Date as a rails til
This commit is contained in:
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
|
||||
warrant a full blog post. These are mostly things I learn by pairing with
|
||||
smart people at [Hashrocket](http://hashrocket.com/).
|
||||
|
||||
_461 TILs and counting..._
|
||||
_462 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -278,6 +278,7 @@ _461 TILs and counting..._
|
||||
|
||||
### Rails
|
||||
|
||||
- [Advance The Date](rails/advance-the-date.md)
|
||||
- [All or Nothing Database Transactions](rails/all-or-nothing-database-transactions.md)
|
||||
- [Attach A File With Capybara](rails/attach-a-file-with-capybara.md)
|
||||
- [Attribute Getter without the Recursion](rails/attribute-getter-without-the-recursion.md)
|
||||
|
||||
17
rails/advance-the-date.md
Normal file
17
rails/advance-the-date.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Advance The Date
|
||||
|
||||
In Rails land, you can advance a date forward and backward with the
|
||||
`#advance` method:
|
||||
|
||||
```ruby
|
||||
> Date.today
|
||||
=> Wed, 31 Aug 2016
|
||||
> Date.today.advance(days: 1)
|
||||
=> Thu, 01 Sep 2016
|
||||
> Date.today.advance(months: 1)
|
||||
=> Fri, 30 Sep 2016
|
||||
> Date.today.advance(months: -2)
|
||||
=> Thu, 30 Jun 2016
|
||||
```
|
||||
|
||||
h/t Dillon Hafer
|
||||
Reference in New Issue
Block a user