Class: ParameterSubstitution::Formatters::DateTimeCustom
- Inherits:
-
DateTimeFormat
- Object
- Base
- DateTimeFormat
- ParameterSubstitution::Formatters::DateTimeCustom
- Defined in:
- lib/parameter_substitution/formatters/date_time_custom.rb
Constant Summary
Constants inherited from DateTimeFormat
ParameterSubstitution::Formatters::DateTimeFormat::MINIMUM_INTEGER_TIME
Class Method Summary collapse
Instance Method Summary collapse
- #format(value) ⇒ Object
-
#initialize(from_formatting_string, to_formatting_string, from_time_zone, to_time_zone) ⇒ DateTimeCustom
constructor
A new instance of DateTimeCustom.
Methods inherited from DateTimeFormat
from_custom_time, from_parse, from_unix_time_ms, from_unix_time_sec, from_yyyymmddhhmmssss, parse_to_time
Methods inherited from Base
encoding, format, key, parse_duration
Constructor Details
#initialize(from_formatting_string, to_formatting_string, from_time_zone, to_time_zone) ⇒ DateTimeCustom
Returns a new instance of DateTimeCustom.
13 14 15 16 17 |
# File 'lib/parameter_substitution/formatters/date_time_custom.rb', line 13 def initialize(from_formatting_string, to_formatting_string, from_time_zone, to_time_zone) @parse_options = { from_formatting: from_formatting_string, from_time_zone: from_time_zone } @to_formatting = to_formatting_string @to_time_zone = to_time_zone end |
Class Method Details
.description ⇒ Object
9 10 11 |
# File 'lib/parameter_substitution/formatters/date_time_custom.rb', line 9 def self.description "Formats a Date String with the provided formatting, converts it's time zone, and then converts it to the desired formatting string." end |
.has_parameters? ⇒ Boolean
5 6 7 |
# File 'lib/parameter_substitution/formatters/date_time_custom.rb', line 5 def self.has_parameters? true end |
Instance Method Details
#format(value) ⇒ Object
19 20 21 |
# File 'lib/parameter_substitution/formatters/date_time_custom.rb', line 19 def format(value) self.class.parse_to_time(value, @parse_options)&.in_time_zone(@to_time_zone)&.strftime(@to_formatting).to_s # rubocop:disable Lint/SafeNavigationChain end |