Class: Jamf::TimeZone

Inherits:
CollectionResource show all
Extended by:
Immutable, UnCreatable, UnDeletable
Defined in:
lib/jamf/api/resources/collection_resources/time_zone.rb

Overview

A building defined in the JSS

Constant Summary collapse

RSRC_VERSION =

Constants

'v1'.freeze
RSRC_PATH =
'time-zones'.freeze
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,
    aliases: [:id]
  },

  # @!attribute displayName
  #   @return [String]
  displayName: {
    class: :string,
    identifier: true,
    aliases: [:name]
  },

  # @!attribute [r] region
  #   @return [String]
  region: {
    class: :string
  }
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Jamf::JSONObject

Instance Attribute Details

#regionString (readonly)

Returns:



# File 'lib/jamf/api/resources/collection_resources/time_zone.rb', line 71

Class Method Details

.creatable?Boolean Originally defined in module UnCreatable

Returns:

  • (Boolean)

.deletable?Boolean Originally defined in module UnDeletable

Returns:

  • (Boolean)

.mutable?Boolean Originally defined in module Immutable

Returns:

  • (Boolean)

Instance Method Details

#localtime(othertime) ⇒ Time

Give a Time object, whats the matching local time in this TimeZone?

Parameters:

  • othertime (Time)

    a Time or Jamf::Timestamp object

Returns:

  • (Time)

    othertime, in the local time in this time zone



113
114
115
# File 'lib/jamf/api/resources/collection_resources/time_zone.rb', line 113

def localtime(othertime)
  othertime.getlocal utc_offset
end

#utc_offsetInteger

Returns The offset from UTC, in seconds.

Returns:

  • (Integer)

    The offset from UTC, in seconds



97
98
99
100
101
102
103
104
105
# File 'lib/jamf/api/resources/collection_resources/time_zone.rb', line 97

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_strInteger

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

Returns:

  • (Integer)

    The offset from UTC, as a string



88
89
90
91
92
93
# File 'lib/jamf/api/resources/collection_resources/time_zone.rb', line 88

def utc_offset_str
  return @utc_offset_str if @utc_offset_str

  displayName =~ /\(([+-]\d{4})\)/
  @utc_offset_str = Regexp.last_match[1]
end