Class: AllscriptsUnityClient::Timezone
- Inherits:
-
Object
- Object
- AllscriptsUnityClient::Timezone
- Defined in:
- lib/allscripts_unity_client/timezone.rb
Instance Attribute Summary collapse
-
#tzinfo ⇒ Object
Returns the value of attribute tzinfo.
Instance Method Summary collapse
- #==(timezone) ⇒ Object
-
#initialize(zone_identifier) ⇒ Timezone
constructor
A new instance of Timezone.
-
#local_to_utc(datetime) ⇒ Object
Use TZInfo to convert a given UTC datetime into a local.
- #utc_to_local(datetime = nil) ⇒ Object
Constructor Details
#initialize(zone_identifier) ⇒ Timezone
Returns a new instance of Timezone.
8 9 10 11 12 |
# File 'lib/allscripts_unity_client/timezone.rb', line 8 def initialize(zone_identifier) raise ArgumentError, 'zone_identifier can not be nil' if zone_identifier.nil? @tzinfo = TZInfo::Timezone.get(zone_identifier) end |
Instance Attribute Details
#tzinfo ⇒ Object
Returns the value of attribute tzinfo.
6 7 8 |
# File 'lib/allscripts_unity_client/timezone.rb', line 6 def tzinfo @tzinfo end |
Instance Method Details
#==(timezone) ⇒ Object
24 25 26 27 |
# File 'lib/allscripts_unity_client/timezone.rb', line 24 def ==(timezone) return false if !timezone.is_a?(Timezone) @tzinfo == timezone.tzinfo end |
#local_to_utc(datetime) ⇒ Object
Use TZInfo to convert a given UTC datetime into a local
16 17 18 |
# File 'lib/allscripts_unity_client/timezone.rb', line 16 def local_to_utc(datetime) convert_with_timezone(:local_to_utc, datetime) end |
#utc_to_local(datetime = nil) ⇒ Object
20 21 22 |
# File 'lib/allscripts_unity_client/timezone.rb', line 20 def utc_to_local(datetime = nil) convert_with_timezone(:utc_to_local, datetime) end |