TimezoneParser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 283ce418cd48824722fa6ec6ee89a6edf454a4b8
4
+ data.tar.gz: f7a5c691908249119b2408624421b6f0d072f9c1
5
+ SHA512:
6
+ metadata.gz: 27f8e4337def4fabed6c8217586c16757ace85bf6846de00f800f359bb590183c43bac98a7c783e1aeff1deb9efb63d9def216ffeed8c0aa42bfc7158b308dcf
7
+ data.tar.gz: 8bfd9f2032bb67c576a4d6e60a66a0c90ee8833e1e2b2adad0b8f7fc6d26c5f080c7ed3ad226165f01259f8901a0689aadda65ad1b548ca76586e7f055511e5f
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ vendor/
18
+ tmp
19
+ /data/*.dat
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development, :test do
4
+ gem 'redcarpet', :platforms => [:ruby, :mswin, :mingw]
5
+ gem 'kramdown', :platforms => :jruby
6
+ gem 'coveralls', require: false if ENV['CI']
7
+ end
8
+
9
+ # Specify your gem's dependencies in TimezoneParser.gemspec
10
+ gemspec
data/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # TimezoneParser
2
+
3
+ ## Probably the best, most complete Timezone parsing library ever made!
4
+
5
+ Library for parsing Timezone names and abbreviations to corresponding UTC offsets and much more. Supports multiple languages.
6
+
7
+ ## Features
8
+
9
+ * Parse Timezone name to UTC offset
10
+ * Support for all TZ database abbreviations
11
+ * Ruby on Rails Timezone names supported
12
+ * Recognition of localized timezone names
13
+ * Check if string is a valid Timezone or abbreviation
14
+ * Present and Historical Timezones and offsets
15
+ * Filter results by Time, Region, Locale and DST
16
+
17
+
18
+ Input formats:
19
+
20
+ * Timezone abbreviations (eg. "EST")
21
+ * Timezone names (eg. "China Summer Time")
22
+ * Localized Timezone names in different languages (eg. "阿尤恩")
23
+ * Windows zone names (eg. "Azerbaijan Summer Time")
24
+ * Localized Windows zone names (eg. "كوريا - التوقيت الرسمي")
25
+ * Ruby on Rails Timezone names (eg. "Eastern Time (US & Canada)")
26
+ * Translated Ruby on Rails Timezone names (eg. "노보시비르스크")
27
+
28
+
29
+ Output formats:
30
+
31
+ * UTC offsets (eg. "-18000")
32
+ * Timezone identifiers (eg. "Europe/Istanbul")
33
+ * Original Zone (eg. "Mid-Atlantic Standard Time")
34
+ * Metazones (eg. "North_Mariana")
35
+
36
+
37
+ ## Installation
38
+
39
+ Add this line to your application's Gemfile:
40
+
41
+ gem 'TimezoneParser'
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+ Or install it yourself as:
48
+
49
+ $ gem install TimezoneParser
50
+
51
+
52
+ ### Dependencies
53
+
54
+ * tzinfo (only required for Timezone offsets in some cases)
55
+ * insensitive_hash
56
+
57
+ ## Usage Example
58
+
59
+ ### To get UTC offsets from Timezone abbreviations
60
+
61
+ ```ruby
62
+ > require 'timezone_parser'
63
+ => true
64
+ > offsets = TimezoneParser::Abbreviation.new('FKT').getOffsets
65
+ => [-14400]
66
+ > offsets.first
67
+ => -14400
68
+ ```
69
+
70
+ ### Timezone name to Timezone identifier
71
+
72
+ ```ruby
73
+ > TimezoneParser::Timezone.new('Nord-Marianene-tid').getTimezones
74
+ => ["Pacific/Saipan"]
75
+ ```
76
+
77
+ ### Localized Windows zone to original Windows zone identifier
78
+
79
+ ```ruby
80
+ > TimezoneParser::WindowsZone.new('Jerusalem (normaltid)').getZone
81
+ => "Israel Standard Time"
82
+ ```
83
+
84
+ ### Find actual Timezones from uknown platform-dependent Ruby zone
85
+
86
+ ```ruby
87
+ > tz = Time.now.zone # on localized Windows
88
+ => "FLE standarta laiks"
89
+ > TimezoneParser::getTimezones(tz)
90
+ => ["Europe/Helsinki", "Europe/Kiev", "Europe/Mariehamn", "Europe/Riga", "Europe/Simferopol", "Europe/Sofia", "Europe/Tallinn", "Europe/Uzhgorod", "Europe/Vilnius", "Europe/Zaporozhye"]
91
+ ```
92
+
93
+ ## Documentation
94
+
95
+ YARD with markdown is used for documentation (`redcarpet` required)
96
+
97
+ ## Specs
98
+
99
+ RSpec and simplecov are required, to run tests just `rake spec`
100
+ code coverage will also be generated
101
+
102
+ ## Code status
103
+ [![Gem Version](https://badge.fury.io/rb/TimezoneParser.png)](http://badge.fury.io/rb/TimezoneParser)
104
+ [![Build Status](https://travis-ci.org/davispuh/TimezoneParser.png?branch=master)](https://travis-ci.org/davispuh/TimezoneParser)
105
+ [![Dependency Status](https://gemnasium.com/davispuh/TimezoneParser.png)](https://gemnasium.com/davispuh/TimezoneParser)
106
+ [![Coverage Status](https://coveralls.io/repos/davispuh/TimezoneParser/badge.png)](https://coveralls.io/r/davispuh/TimezoneParser)
107
+ [![Code Climate](https://codeclimate.com/github/davispuh/TimezoneParser.png)](https://codeclimate.com/github/davispuh/TimezoneParser)
108
+
109
+ ## Unlicense
110
+
111
+ ![Copyright-Free](http://unlicense.org/pd-icon.png)
112
+
113
+ All text, documentation, code and files in this repository are in public domain (including this text, README).
114
+ It means you can copy, modify, distribute and include in your own work/code, even for commercial purposes, all without asking permission.
115
+
116
+ [About Unlicense](http://unlicense.org/)
117
+
118
+ ## Contributing
119
+
120
+ Feel free to improve as you see.
121
+
122
+ 1. Fork it
123
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
124
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
125
+ 4. Push to the branch (`git push origin my-new-feature`)
126
+ 5. Create new Pull Request
127
+
128
+
129
+ **Warning**: By sending pull request to this repository you dedicate any and all copyright interest in pull request (code files and all other) to the public domain. (files will be in public domain even if pull request doesn't get merged)
130
+
131
+ Also before sending pull request you acknowledge that you own all copyrights or have authorization to dedicate them to public domain.
132
+
133
+ If you don't want to dedicate code to public domain or if you're not allowed to (eg. you don't own required copyrights) then DON'T send pull request.
data/Rakefile ADDED
@@ -0,0 +1,160 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+ require 'yard'
5
+ require 'yaml'
6
+ require 'pathname'
7
+ require 'timezone_parser/data'
8
+
9
+ desc 'Default: run specs.'
10
+ task :default => :spec
11
+
12
+ desc 'Run specs'
13
+ RSpec::Core::RakeTask.new(:spec) do |t|
14
+ end
15
+
16
+ YARD::Rake::YardocTask.new(:doc) do |t|
17
+ end
18
+
19
+ def data_location
20
+ TimezoneParser::Data::DataDir
21
+ end
22
+
23
+ def vendor_location
24
+ TimezoneParser::Data::VendorDir
25
+ end
26
+
27
+ def repo_location
28
+ TimezoneParser::Data::RootDir.parent.parent
29
+ end
30
+
31
+ def update
32
+ require 'timezone_parser/data/tzinfo'
33
+ require 'timezone_parser/data/cldr'
34
+ require 'active_support/time'
35
+ TimezoneParser::TZInfo::init
36
+ countries = TimezoneParser::TZInfo::getTimezoneCountries
37
+ abbreviations = TimezoneParser::TZInfo::getAbbreviations
38
+ timezones = TimezoneParser::CLDR::getTimezones
39
+ metazones = TimezoneParser::CLDR::getMetazones
40
+ windowsZones = TimezoneParser::CLDR::getWindowsZones
41
+ TimezoneParser::CLDR::updateAbbreviations(abbreviations)
42
+ version = { 'TZInfo' => TimezoneParser::TZInfo::getVersion, 'CLDR' => TimezoneParser::CLDR::getVersion, 'Rails' => ActiveSupport::VERSION::STRING, 'WindowsZones' => nil }
43
+ File.write(data_location + 'countries.yml', countries.to_yaml)
44
+ File.write(data_location + 'timezones.yml', timezones.to_yaml)
45
+ File.write(data_location + 'metazones.yml', metazones.to_yaml)
46
+ File.write(data_location + 'windows_timezones.yml', windowsZones.to_yaml)
47
+ abbreviations = Hash[abbreviations.to_a.sort_by { |d| d.first } ]
48
+ File.write(data_location + 'abbreviations.yml', abbreviations.to_yaml)
49
+ rails = Hash[ActiveSupport::TimeZone::MAPPING.to_a.sort_by { |d| d.first } ]
50
+ File.write(data_location + 'rails.yml', rails.to_yaml)
51
+ File.write(data_location + 'version.yml', version.to_yaml)
52
+ end
53
+
54
+ def update_rails
55
+ timezone_path = repo_location + 'i18n-timezones' + 'rails' + 'locale'
56
+ names = {}
57
+ timezone_path.each_child(false) do |file|
58
+ YAML.load_file(timezone_path + file).each do |locale, data|
59
+ namesArray = data['timezones'].invert.to_a
60
+ namesArray.map { |e| e.map!(&:strip) }
61
+ names[locale] = Hash[namesArray.sort_by { |d| d.first } ]
62
+ end
63
+ end
64
+ File.write(data_location + 'rails_i18n.yml', names.to_yaml)
65
+ end
66
+
67
+ def update_windows
68
+ os = Gem::Platform.local.os
69
+ if (os == 'mingw32' or os == 'mingw64')
70
+ require 'timezone_parser/data/windows'
71
+ version = YAML.load_file(data_location + 'version.yml')
72
+ version['WindowsZones'] = TimezoneParser::Windows.getVersion
73
+ if version['WindowsZones'].nil?
74
+ $stderr.puts TimezoneParser::Windows.errors
75
+ else
76
+ timezones = TimezoneParser::Windows.getTimezones
77
+ File.write(data_location + 'windows_offsets.yml', timezones.to_yaml)
78
+ File.write(data_location + 'version.yml', version.to_yaml)
79
+ end
80
+ else
81
+ puts 'Sorry, you must be running Windows'
82
+ end
83
+ end
84
+
85
+ def import_timezones
86
+ require 'timezone_parser/data/windows'
87
+ os = Gem::Platform.local.os
88
+ if (os == 'mingw32' or os == 'mingw64')
89
+ metazones = YAML.load_file(vendor_location + 'tzres.yml')
90
+ offsets = TimezoneParser::Windows.getMUIOffsets
91
+ metazone_names = TimezoneParser::Windows.parseMetazones(metazones, offsets)
92
+ File.write(data_location + 'windows_zonenames.yml', metazone_names.to_yaml)
93
+ else
94
+ puts 'Sorry, you must be running Windows'
95
+ end
96
+ end
97
+
98
+ def download_tz
99
+ require 'timezone_parser/data/tzinfo'
100
+ TimezoneParser::TZInfo::download
101
+ end
102
+
103
+ def download_cldr
104
+ require 'timezone_parser/data/cldr'
105
+ TimezoneParser::CLDR::download
106
+ end
107
+
108
+ desc 'Download TZ data'
109
+ task 'download:tz' do
110
+ download_tz
111
+ end
112
+
113
+ desc 'Download CLDR data'
114
+ task 'download:cldr' do
115
+ download_cldr
116
+ end
117
+
118
+ desc 'Download TZ and CLDR data'
119
+ task :download do
120
+ download_tz
121
+ download_cldr
122
+ end
123
+
124
+ desc 'Update data'
125
+ task :update do
126
+ update
127
+ end
128
+
129
+ desc 'Update Rails data'
130
+ task 'update:rails' do
131
+ update_rails
132
+ end
133
+
134
+ desc 'Update Windows data'
135
+ task 'update:windows' do
136
+ update_windows
137
+ end
138
+
139
+ desc 'Import Windows localized timezones from tzres.yml'
140
+ task 'update:windowszones' do
141
+ import_timezones
142
+ end
143
+
144
+ desc 'Update all data'
145
+ task 'update:all' do
146
+ update
147
+ update_rails
148
+ update_windows
149
+ import_timezones
150
+ end
151
+
152
+ desc 'Export data'
153
+ task 'export' do
154
+ ['abbreviations.yml', 'timezones.yml', 'countries.yml', 'metazones.yml',
155
+ 'windows_zonenames.yml', 'windows_timezones.yml', 'windows_offsets.yml',
156
+ 'rails.yml', 'rails_i18n.yml'].each do |name|
157
+ path = data_location + name
158
+ Marshal.dump(YAML.load_file(path), File.open(path.dirname + (path.basename('.*').to_s + '.dat'), 'wb'))
159
+ end
160
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'timezone_parser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'TimezoneParser'
8
+ spec.version = TimezoneParser::VERSION
9
+ spec.authors = ['Dāvis']
10
+ spec.email = ['davispuh@gmail.com']
11
+ spec.description = 'Library for parsing Timezone names and abbrevations to corresponding UTC offsets and much more'
12
+ spec.summary = 'Parse Timezone names written in any language to offsets and TimeZone identifiers'
13
+ spec.homepage = 'https://github.com/davispuh/TimezoneParser'
14
+ spec.license = 'UNLICENSE'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.files.delete_if { |name| name[-4, 4] == '.yml' }
18
+ spec.files << 'data/version.yml'
19
+ ['abbreviations.dat', 'countries.dat', 'metazones.dat',
20
+ 'rails.dat', 'rails_i18n.dat', 'timezones.dat',
21
+ 'windows_offsets.dat', 'windows_timezones.dat', 'windows_zonenames.dat'].each do |name|
22
+ spec.files << 'data/' + name
23
+ end
24
+
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'tzinfo'
30
+ spec.add_runtime_dependency 'insensitive_hash'
31
+
32
+ spec.add_development_dependency 'bundler', '>= 1.3'
33
+ spec.add_development_dependency 'rake'
34
+ spec.add_development_dependency 'rspec'
35
+ spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'yard'
37
+ spec.add_development_dependency 'tzinfo-data'
38
+ spec.add_development_dependency 'ruby-cldr'
39
+ spec.add_development_dependency 'activesupport'
40
+ end
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
data/data/version.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ TZInfo: 2013i
3
+ CLDR: 24
4
+ Rails: 4.1.0.rc1
5
+ WindowsZones: 7de0000
@@ -0,0 +1,159 @@
1
+ # encoding: utf-8
2
+ require 'timezone_parser/version'
3
+ require 'timezone_parser/data'
4
+ require 'timezone_parser/zone_info'
5
+ require 'timezone_parser/abbreviation'
6
+ require 'timezone_parser/timezone'
7
+ require 'timezone_parser/windows_zone'
8
+ require 'timezone_parser/rails_zone'
9
+
10
+ # TimezoneParser module
11
+ module TimezoneParser
12
+
13
+ protected
14
+ @@Modules = []
15
+ @@Regions = []
16
+ @@Locales = []
17
+
18
+ public
19
+
20
+ # Modules which to use by default when no modules are specified
21
+ AllModules = [:Abbreviations, :Timezones, :WindowsZones, :RailsZones].freeze
22
+
23
+ # Modules which will be used for TimezoneParser methods if not specified there
24
+ # @return [Array<Symbol>] list containing symbol names for modules to use
25
+ # @see AllModules
26
+ def self.Modules
27
+ @@Modules
28
+ end
29
+
30
+ # Regions which will be used for TimezoneParser methods if not specified there
31
+ #
32
+ # Each region is either ISO 3166-1 alpha-2 code or CLDR territory (UN M.49)
33
+ # @return [Array<String>] list containing region identifiers
34
+ # @see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
35
+ # @see http://www.unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html
36
+ def self.Regions
37
+ @@Regions
38
+ end
39
+
40
+ # Locales which will be used for TimezoneParser methods if not specified there
41
+ #
42
+ # Each locale is language identifier based on IETF BCP 47. Usually is either language identifier or language and country/region identifier
43
+ # @return [Array<String>] list containing locale identifiers
44
+ # @see http://en.wikipedia.org/wiki/IETF_language_tag
45
+ # @see http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
46
+ # @see http://www.unicode.org/cldr/charts/latest/supplemental/language_territory_information.html
47
+ # @see http://msdn.microsoft.com/en-us/library/dd318693.aspx
48
+ def self.Locales
49
+ @@Locales
50
+ end
51
+
52
+ # Load Timezone data in memory from files
53
+ #
54
+ # If no modules are specified it will load default modules
55
+ # @param modules [Array<Symbol>] list of modules
56
+ # @see Modules
57
+ # @see AllModules
58
+ def self.preload(modules = @@Modules)
59
+ modules = AllModules if modules.nil? or modules.empty?
60
+ Data::Storage.preload(modules)
61
+ end
62
+
63
+ # Check if given Timezone name is a valid timezone
64
+ # @param name [String] either Timezone name or abbreviation
65
+ # @param locales [Array<String>] check only for these locales
66
+ # @param modules [Array<Symbol>] list of modules from which to check
67
+ # @return [Boolean] whether Timezone is valid
68
+ # @see Locales
69
+ # @see Modules
70
+ # @see AllModules
71
+ # @see Abbreviation.isValid?
72
+ # @see Timezone.isValid?
73
+ # @see WindowsZone.isValid?
74
+ # @see RailsZone.isValid?
75
+ def self.isValid?(name, locales = @@Locales, modules = @@Modules)
76
+ valid = false
77
+ modules = AllModules if modules.nil? or modules.empty?
78
+ valid = Abbreviation::isValid?(name) if modules.include?(:Abbreviations)
79
+ return valid if valid
80
+
81
+ valid = Timezone::isValid?(name, locales) if modules.include?(:Timezones)
82
+ return valid if valid
83
+
84
+ valid = WindowsZone::isValid?(name, locales) if modules.include?(:WindowsZones)
85
+ return valid if valid
86
+
87
+ valid = RailsZone::isValid?(name, locales) if modules.include?(:RailsZones)
88
+ valid
89
+ end
90
+
91
+ # Get UTC offsets in seconds for given Timezone name
92
+ # @param name [String] either Timezone name or abbreviation
93
+ # @param toTime [DateTime] look for offsets which came into effect before this date, exclusive
94
+ # @param fromTime [DateTime] look for offsets which came into effect at this date, inclusive
95
+ # @param regions [Array<String>] look for offsets only for these regions
96
+ # @param locales [Array<String>] search Timezone name only for these locales
97
+ # @param type [Symbol] specify whether offset should be :standard time or :daylight
98
+ # @param all [Boolean] specify whether should search for all offsets or return as soon as found any
99
+ # @param modules [Array<Symbol>] list of modules from which to search
100
+ # @return [Array<Fixnum>] list of timezone offsets in seconds
101
+ # @see Regions
102
+ # @see Locales
103
+ # @see Modules
104
+ # @see AllModules
105
+ # @see Abbreviation.getOffsets
106
+ # @see Timezone.getOffsets
107
+ # @see WindowsZone.getOffsets
108
+ # @see RailsZone.getOffsets
109
+ def self.getOffsets(name, toTime = nil, fromTime = nil, regions = @@Regions, locales = @@Locales, type = nil, all = true, modules = @@Modules)
110
+ offsets = SortedSet.new
111
+ modules = AllModules if modules.nil? or modules.empty?
112
+ offsets += Abbreviation::getOffsets(name, toTime, fromTime, regions, type) if modules.include?(:Abbreviations)
113
+ return offsets.to_a if not all and not offsets.empty?
114
+
115
+ offsets += Timezone::getOffsets(name, toTime, fromTime, locales, regions, all) if modules.include?(:Timezones)
116
+ return offsets.to_a if not all and not offsets.empty?
117
+
118
+ offsets += WindowsZone::getOffsets(name, locales, all) if modules.include?(:WindowsZones)
119
+ return offsets.to_a if not all and not offsets.empty?
120
+
121
+ offsets += RailsZone::getOffsets(name, toTime, fromTime, locales, all) if modules.include?(:RailsZones)
122
+ offsets.to_a
123
+ end
124
+
125
+ # Get Timezone identifiers for given Timezone name
126
+ # @param name [String] either Timezone name or abbreviation
127
+ # @param toTime [DateTime] look for timezones which came into effect before this date, exclusive
128
+ # @param fromTime [DateTime] look for timezones which came into effect at this date, inclusive
129
+ # @param regions [Array<String>] look for timezones only for these regions
130
+ # @param locales [Array<String>] search Timezone name only for these locales
131
+ # @param type [Symbol] specify whether timezones should be :standard time or :daylight
132
+ # @param all [Boolean] specify whether should search for all timezones or return as soon as found any
133
+ # @param modules [Array<Symbol>] list of modules from which to search
134
+ # @return [Array<String>] list of timezone identifiers
135
+ # @see Regions
136
+ # @see Locales
137
+ # @see Modules
138
+ # @see AllModules
139
+ # @see Abbreviation.getTimezones
140
+ # @see Timezone.getTimezones
141
+ # @see WindowsZone.getTimezones
142
+ # @see RailsZone.getTimezones
143
+ def self.getTimezones(name, toTime = nil, fromTime = nil, regions = @@Regions, locales = @@Locales, type = nil, all = true, modules = @@Modules)
144
+ timezones = SortedSet.new
145
+ modules = AllModules if modules.nil? or modules.empty?
146
+ timezones += Abbreviation::getTimezones(name, toTime, fromTime, regions, type) if modules.include?(:Abbreviations)
147
+ return timezones.to_a if not all and not timezones.empty?
148
+
149
+ timezones += Timezone::getTimezones(name, toTime, fromTime, locales, regions, all) if modules.include?(:Timezones)
150
+ return timezones.to_a if not all and not timezones.empty?
151
+
152
+ timezones += WindowsZone::getTimezones(name, locales, regions, all) if modules.include?(:WindowsZones)
153
+ return timezones.to_a if not all and not timezones.empty?
154
+
155
+ timezones += RailsZone::getTimezones(name, locales, all) if modules.include?(:RailsZones)
156
+ timezones.to_a
157
+ end
158
+ end
159
+