Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/ndr_support/date_and_time_extensions.rb
Overview
Extend standard Time class with our custom to_s overrides
Instance Method Summary collapse
- #orig_to_s ⇒ 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_s ⇒ Object
45 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 45 alias orig_to_s to_s |
#to_iso ⇒ Object
to_iso output must be SQL safe for security reasons
41 42 43 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 41 def to_iso strftime('%Y-%m-%dT%H:%M:%S') 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
50 51 52 53 54 55 56 |
# File 'lib/ndr_support/date_and_time_extensions.rb', line 50 def to_s(format = :default) if format == :default DATE_FORMATS.key?(:default) ? to_fs(:default) : orig_to_s else orig_to_s(format) end end |