Class: Date
- Defined in:
- lib/ruby-rails-extensions/extensions/todays_date.rb,
lib/ruby-rails-extensions/extensions/input.rb,
lib/ruby-rails-extensions/extensions/month_year.rb,
lib/ruby-rails-extensions/extensions/safe_parse.rb,
lib/ruby-rails-extensions/extensions/day_of_week.rb,
lib/ruby-rails-extensions/extensions/current_week.rb,
lib/ruby-rails-extensions/extensions/display_user.rb,
lib/ruby-rails-extensions/extensions/current_month.rb,
lib/ruby-rails-extensions/extensions/month_and_year.rb
Overview
Requires ‘ActiveSupport::TimeWithZone` and `Time#to_local`
Class Method Summary collapse
-
.safe_parse(str) ⇒ Object
Parses the ‘str` and returns `nil` if invalid.
-
.todays_date ⇒ Date
Returns today according to Eastern time.
Instance Method Summary collapse
-
#current_month ⇒ Object
:nodoc:.
- #current_week ⇒ Object
-
#day_of_week ⇒ String
-
Full day word.
-
-
#display_user(all = false) ⇒ String
-
mm/dd/yyyy or m/d/yy.
-
-
#input(_all = false) ⇒ String
-
yyyy-mm-dd.
-
-
#month_and_year ⇒ String
-
mm/yy.
-
-
#month_year ⇒ String
-
yyyy-mm.
-
Class Method Details
.safe_parse(str) ⇒ Object
Parses the ‘str` and returns `nil` if invalid
17 18 19 20 21 |
# File 'lib/ruby-rails-extensions/extensions/safe_parse.rb', line 17 def safe_parse(str) parse(str) rescue nil end |
Instance Method Details
#current_month ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/ruby-rails-extensions/extensions/current_month.rb', line 14 def current_month beginning_of_month..end_of_month end |
#current_week ⇒ Object
14 15 16 |
# File 'lib/ruby-rails-extensions/extensions/current_week.rb', line 14 def current_week beginning_of_week..end_of_week end |
#day_of_week ⇒ String
Returns - Full day word.
14 15 16 |
# File 'lib/ruby-rails-extensions/extensions/day_of_week.rb', line 14 def day_of_week strftime('%A') end |
#display_user(all = false) ⇒ String
Returns - mm/dd/yyyy or m/d/yy.
21 22 23 |
# File 'lib/ruby-rails-extensions/extensions/display_user.rb', line 21 def display_user(all = false) strftime(all ? '%m/%d/%Y' : '%-m/%-d/%y') end |
#input(_all = false) ⇒ String
Returns - yyyy-mm-dd.
14 15 16 |
# File 'lib/ruby-rails-extensions/extensions/input.rb', line 14 def input(_all = false) strftime('%F') end |
#month_and_year ⇒ String
Returns - mm/yy.
7 8 9 |
# File 'lib/ruby-rails-extensions/extensions/month_and_year.rb', line 7 def month_and_year strftime('%m/%y') end |
#month_year ⇒ String
Returns - yyyy-mm.
7 8 9 |
# File 'lib/ruby-rails-extensions/extensions/month_year.rb', line 7 def month_year input[0, 7] end |