Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/ndr_support/date_and_time_extensions.rb
Instance Method Summary collapse
-
#orig_to_datetime ⇒ Object
ISO date format.
- #orig_to_s ⇒ Object
- #to_datetime ⇒ Object
-
#to_iso ⇒ Object
to_iso output must be SQL safe for security reasons.
-
#to_s(format = :default) ⇒ Object
Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1) cf.
Instance Method Details
#orig_to_datetime ⇒ Object
ISO date format
11 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 11 alias orig_to_datetime to_datetime |
#orig_to_s ⇒ Object
19 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 19 alias orig_to_s to_s |
#to_datetime ⇒ Object
13 14 15 16 17 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 13 def to_datetime # Default timezone for Date is GMT, not local timezone return in_time_zone.to_datetime if ActiveRecord::Base.default_timezone == :local orig_to_datetime end |
#to_iso ⇒ Object
to_iso output must be SQL safe for security reasons
7 8 9 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 7 def to_iso strftime('%Y-%m-%d') end |
#to_s(format = :default) ⇒ Object
Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1) cf. activesupport-7.0.4/lib/active_support/core_ext/date/deprecated_conversions.rb We keep overriding this for compatibility
24 25 26 27 28 29 30 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 24 def to_s(format = :default) if format == :default to_formatted_s(:default) else orig_to_s(format) end end |