Class: Jamf::TimeZone
- Inherits:
-
JSONObject
- Object
- JSONObject
- Jamf::TimeZone
- Defined in:
- lib/jamf/api/json_objects/time_zone.rb
Overview
A Time Zone known to Jamf Pro
Constant Summary collapse
- OBJECT_MODEL =
Object Model / Attributes See APIObject class documentation for details of how the OBJECT_MODEL hash works.
{ # @!attribute [r] zoneId # @return [String] zoneId: { class: :string, identifier: :primary, read_only: true, aliases: [:id] }, # @!attribute displayName # @return [String] displayName: { class: :string, identifier: true, read_only: true, aliases: [:name] }, # @!attribute [r] region # @return [String] region: { class: :string, read_only: true } }.freeze
Instance Attribute Summary collapse
- #region ⇒ String readonly
Instance Method Summary collapse
-
#localtime(othertime) ⇒ Time
Give a Time object, whats the matching local time in this TimeZone?.
-
#utc_offset ⇒ Integer
The offset from UTC, in seconds.
-
#utc_offset_str ⇒ String
The offset from UTC, as a string.
Constructor Details
This class inherits a constructor from Jamf::JSONObject
Instance Attribute Details
Instance Method Details
#localtime(othertime) ⇒ Time
Give a Time object, whats the matching local time in this TimeZone?
99 100 101 |
# File 'lib/jamf/api/json_objects/time_zone.rb', line 99 def localtime(othertime) othertime.getlocal utc_offset end |
#utc_offset ⇒ Integer
Returns The offset from UTC, in seconds.
83 84 85 86 87 88 89 90 91 |
# File 'lib/jamf/api/json_objects/time_zone.rb', line 83 def utc_offset return @utc_offset if @utc_offset sign = utc_offset_str[0] secs = utc_offset_str[1..2].to_i * 3600 secs += utc_offset_str[3..4].to_i * 60 # negate if needed @utc_offset = sign == '+' ? secs : -secs end |
#utc_offset_str ⇒ String
The offset from UTC, as a string.
This is as it would appear at the end of an ISO8601 formatted time, e.g. -0945 or +1200
Note that ISO8601 accepts the formats: /-hh:mm, /-hhmm, or +/-hh
74 75 76 77 78 79 |
# File 'lib/jamf/api/json_objects/time_zone.rb', line 74 def utc_offset_str return @utc_offset_str if @utc_offset_str displayName =~ /\(([+-]\d{4})\)/ @utc_offset_str = Regexp.last_match[1] end |