Class: TimezoneParser::WindowsZone
- Defined in:
- lib/timezone_parser/windows_zone.rb
Overview
Windows Timezone
Instance Attribute Summary collapse
-
#All ⇒ Object
Returns the value of attribute All.
-
#Locales ⇒ Object
Returns the value of attribute Locales.
-
#Regions ⇒ Object
Returns the value of attribute Regions.
Attributes inherited from ZoneInfo
Class Method Summary collapse
-
.getMetazones(name, locales = nil, all = true) ⇒ Array<String>
Get Metazone identifiers for given Windows Timezone name.
-
.getOffsets(name, locales = nil, all = true) ⇒ Array<Fixnum>
Get UTC offsets in seconds for given Windows Timezone name.
-
.getTimezones(name, locales = nil, regions = nil, all = true) ⇒ Array<String>
Get Timezone identifiers for given Windows Timezone name.
-
.getZone(name, locales = nil, all = true) ⇒ String
Windows Timezone identifier.
-
.isValid?(name, locales = nil) ⇒ Boolean
Check if given Windows Timezone name is a valid timezone.
-
.Locales ⇒ Array<String>
Locales which will be used for WindowsZone methods if not specified there.
-
.Regions ⇒ Array<String>
Regions which will be used for WindowsZone methods if not specified there.
Instance Method Summary collapse
-
#getData ⇒ WindowsData
Windows Timezone data.
-
#getZone ⇒ String
Windows Timezone identifier.
-
#initialize(name) ⇒ WindowsZone
constructor
Windows Timezone instance.
-
#isValid? ⇒ Boolean
Check if timezone is valid.
-
#set(locales = nil, regions = nil, all = true) ⇒ WindowsZone
Set locales, regions and all.
Methods inherited from ZoneInfo
#getMetazones, #getOffsets, #getTimezones, #getTypes, #setTime
Constructor Details
#initialize(name) ⇒ WindowsZone
Windows Timezone instance
56 57 58 59 60 61 |
# File 'lib/timezone_parser/windows_zone.rb', line 56 def initialize(name) @Name = name @Data = WindowsData.new @Valid = nil set(@@Locales.dup, @@Regions.dup, true) end |
Instance Attribute Details
#All ⇒ Object
Returns the value of attribute All.
52 53 54 |
# File 'lib/timezone_parser/windows_zone.rb', line 52 def All @All end |
#Locales ⇒ Object
Returns the value of attribute Locales.
50 51 52 |
# File 'lib/timezone_parser/windows_zone.rb', line 50 def Locales @Locales end |
#Regions ⇒ Object
Returns the value of attribute Regions.
51 52 53 |
# File 'lib/timezone_parser/windows_zone.rb', line 51 def Regions @Regions end |
Class Method Details
.getMetazones(name, locales = nil, all = true) ⇒ Array<String>
Get Metazone identifiers for given Windows Timezone name
156 157 158 |
# File 'lib/timezone_parser/windows_zone.rb', line 156 def self.getMetazones(name, locales = nil, all = true) self.new(name).set(locales, nil, all).getMetazones end |
.getOffsets(name, locales = nil, all = true) ⇒ Array<Fixnum>
Get UTC offsets in seconds for given Windows Timezone name
134 135 136 |
# File 'lib/timezone_parser/windows_zone.rb', line 134 def self.getOffsets(name, locales = nil, all = true) self.new(name).set(locales, nil, all).getOffsets end |
.getTimezones(name, locales = nil, regions = nil, all = true) ⇒ Array<String>
Get Timezone identifiers for given Windows Timezone name
146 147 148 |
# File 'lib/timezone_parser/windows_zone.rb', line 146 def self.getTimezones(name, locales = nil, regions = nil, all = true) self.new(name).set(locales, regions, all).getTimezones end |
.getZone(name, locales = nil, all = true) ⇒ String
Windows Timezone identifier
165 166 167 |
# File 'lib/timezone_parser/windows_zone.rb', line 165 def self.getZone(name, locales = nil, all = true) self.new(name).set(locales, nil, all).getZone end |
.isValid?(name, locales = nil) ⇒ Boolean
Check if given Windows Timezone name is a valid timezone
124 125 126 |
# File 'lib/timezone_parser/windows_zone.rb', line 124 def self.isValid?(name, locales = nil) self.new(name).set(locales).isValid? end |
.Locales ⇒ Array<String>
Locales which will be used for WindowsZone methods if not specified there
Each locale consists of language identifier and country/region identifier
37 38 39 |
# File 'lib/timezone_parser/windows_zone.rb', line 37 def self.Locales @@Locales end |
.Regions ⇒ Array<String>
Regions which will be used for WindowsZone methods if not specified there
Each region is either ISO 3166-1 alpha-2 code
46 47 48 |
# File 'lib/timezone_parser/windows_zone.rb', line 46 def self.Regions @@Regions end |
Instance Method Details
#getData ⇒ WindowsData
Windows Timezone data
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/timezone_parser/windows_zone.rb', line 94 def getData unless @Loaded @Loaded = true @Valid = false locales = @Locales locales = Data::Storage.WindowsZones.keys if locales.empty? locales.each do |locale| next unless Data::Storage.WindowsZones.has_key?(locale) entry = Data::Storage.WindowsZones[locale][@Name] if entry @Data.processEntry(entry, @Regions) @Valid = true return @Data unless @All end end end @Data end |
#getZone ⇒ String
Windows Timezone identifier
115 116 117 |
# File 'lib/timezone_parser/windows_zone.rb', line 115 def getZone getData.WindowsZone end |
#isValid? ⇒ Boolean
Check if timezone is valid
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/timezone_parser/windows_zone.rb', line 79 def isValid? if @Valid.nil? locales = @Locales locales = Data::Storage.WindowsZones.keys if locales.empty? locales.each do |locale| next unless Data::Storage.WindowsZones.has_key?(locale) @Valid = Data::Storage.WindowsZones[locale].has_key?(@Name) return @Valid if @Valid end end @Valid = false end |
#set(locales = nil, regions = nil, all = true) ⇒ WindowsZone
Set locales, regions and all
70 71 72 73 74 75 |
# File 'lib/timezone_parser/windows_zone.rb', line 70 def set(locales = nil, regions = nil, all = true) @Locales = locales unless locales.nil? @Regions = regions unless regions.nil? @All = all ? true : false self end |