Class: Reprise::TimeZoneIdentifier Private
- Inherits:
-
Object
- Object
- Reprise::TimeZoneIdentifier
- Defined in:
- lib/reprise/time_zone_identifier.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- UTC_TIME_ZONE_IDENTIFIER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"Etc/UTC"
Instance Method Summary collapse
-
#initialize(time_zone: nil, datetime_source:) ⇒ TimeZoneIdentifier
constructor
private
A new instance of TimeZoneIdentifier.
-
#to_s ⇒ String
private
Defaults to UTC if no time zone is passed and the datetime source lacks time zone information.
Constructor Details
#initialize(time_zone: nil, datetime_source:) ⇒ TimeZoneIdentifier
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TimeZoneIdentifier.
21 22 23 24 |
# File 'lib/reprise/time_zone_identifier.rb', line 21 def initialize(time_zone: nil, datetime_source:) @time_zone = time_zone @datetime_source = datetime_source end |
Instance Method Details
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defaults to UTC if no time zone is passed and the datetime source lacks time zone information.
29 30 31 32 33 34 35 36 |
# File 'lib/reprise/time_zone_identifier.rb', line 29 def to_s return ActiveSupport::TimeZone.find_tzinfo(time_zone).identifier if time_zone return datetime_source.time_zone.tzinfo.identifier if datetime_source.is_a?(ActiveSupport::TimeWithZone) UTC_TIME_ZONE_IDENTIFIER rescue TZInfo::InvalidTimezoneIdentifier raise InvalidTimeZoneError, invalid_time_zone_identifier_error end |