From 68146828dc3b477f0d9afe7766becee8317b7c4a Mon Sep 17 00:00:00 2001 From: Surender Date: Fri, 26 Feb 2016 11:40:56 +0530 Subject: [PATCH 1/3] on_weekday?, on_weekend? and days_in_year functions added --- ...ime_option_to_next_and_prev_week_rails5.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md index 234a16d..c497ca0 100644 --- a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md +++ b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md @@ -49,4 +49,48 @@ Using this option, we can now get next week date from the current time. Time.current.prev_week(same_time: true) => Mon, 01 Feb 2016 09:16:50 UTC +00:00 +``` + +In addition to that, Rails % has come with some features... + +We can check whether the given date is Weekends or not. + +```ruby + Time.current + => Fri, 12 Feb 2016 09:15:10 UTC +00:00 + + Time.current.on_weekend? + => false + + Time.current.tomorrow + => Sat, 12 Feb 2016 09:15:10 UTC +00:00 + + Time.current.tomorrow.on_weekend? + => true +``` + +Similar to that we can check the Weekdays. + +```ruby + Time.current + => Fri, 12 Feb 2016 09:15:10 UTC +00:00 + + Time.current.on_weekday? + => true + + Time.current.tomorrow + => Sat, 12 Feb 2016 09:15:10 UTC +00:00 + + Time.current.tomorrow.on_weekend? + => false +``` + +We can get the number of days in a Year with `Time.day_in_year` method. + +```ruby + Time.days_in_year + => 366 + + Time.days_in_year(2015) + => 365 ``` \ No newline at end of file From 0ca1ac455465818ac41f81dfa08c69e824f011bd Mon Sep 17 00:00:00 2001 From: Harry Suren Date: Fri, 26 Feb 2016 11:44:48 +0530 Subject: [PATCH 2/3] Update 2016-02-24-same_time_option_to_next_and_prev_week_rails5.md --- ...6-02-24-same_time_option_to_next_and_prev_week_rails5.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md index c497ca0..d234b07 100644 --- a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md +++ b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md @@ -1,8 +1,8 @@ --- title: Get same time of next week and previous week in rails 5 tip-number: 13 -tip-username: Logesh -tip-username-profile: https://github.com/logeshmallow +tip-username: Logesh, Surender Thillainathan +tip-username-profile: https://github.com/logeshmallow https://github.com/harrysuren tip-description: We can get the next week or the previous week with the current time using this methods. --- @@ -93,4 +93,4 @@ We can get the number of days in a Year with `Time.day_in_year` method. Time.days_in_year(2015) => 365 -``` \ No newline at end of file +``` From 9eb2aa8e94da5702f64bad6c611a27e2da8a2f3b Mon Sep 17 00:00:00 2001 From: Harry Suren Date: Fri, 4 Mar 2016 15:31:49 +0530 Subject: [PATCH 3/3] Update 2016-02-24-same_time_option_to_next_and_prev_week_rails5.md --- ...016-02-24-same_time_option_to_next_and_prev_week_rails5.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md index d234b07..4473157 100644 --- a/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md +++ b/rails_tip/2016-02-24-same_time_option_to_next_and_prev_week_rails5.md @@ -3,7 +3,7 @@ title: Get same time of next week and previous week in rails 5 tip-number: 13 tip-username: Logesh, Surender Thillainathan tip-username-profile: https://github.com/logeshmallow https://github.com/harrysuren -tip-description: We can get the next week or the previous week with the current time using this methods. +tip-description: ActiveSupport improvements. --- @@ -51,7 +51,7 @@ Using this option, we can now get next week date from the current time. => Mon, 01 Feb 2016 09:16:50 UTC +00:00 ``` -In addition to that, Rails % has come with some features... +In addition to that, Rails 5 has come with some features... We can check whether the given date is Weekends or not.