From 3e173b8d176f3a8bcbc81ad563cd607f06482651 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 31 Aug 2016 09:11:39 -0500 Subject: [PATCH] Add Advance The Date as a rails til --- README.md | 3 ++- rails/advance-the-date.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 rails/advance-the-date.md diff --git a/README.md b/README.md index f2d580b..7ebcf03 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/rails/advance-the-date.md b/rails/advance-the-date.md new file mode 100644 index 0000000..8ffcb2b --- /dev/null +++ b/rails/advance-the-date.md @@ -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