TimezoneParser 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 283ce418cd48824722fa6ec6ee89a6edf454a4b8
4
- data.tar.gz: f7a5c691908249119b2408624421b6f0d072f9c1
3
+ metadata.gz: ad1e481a9230be8371756904933dded13a0483f7
4
+ data.tar.gz: b602468cb7d2e28e8bf69c427eee8bfbaa4d9889
5
5
  SHA512:
6
- metadata.gz: 27f8e4337def4fabed6c8217586c16757ace85bf6846de00f800f359bb590183c43bac98a7c783e1aeff1deb9efb63d9def216ffeed8c0aa42bfc7158b308dcf
7
- data.tar.gz: 8bfd9f2032bb67c576a4d6e60a66a0c90ee8833e1e2b2adad0b8f7fc6d26c5f080c7ed3ad226165f01259f8901a0689aadda65ad1b548ca76586e7f055511e5f
6
+ metadata.gz: a0588231219e5c9c8303dd0e920f9cc2b493ffe49c16d33a60f6dc3639af715e71ceefdcb7019653b5ceb05bb5b3a9a72b517cc3a1174d1a4dbe1ae9f4945f6c
7
+ data.tar.gz: ad395662299d90987b17e04682a93a6505d0abb2f993b775a8f0beecca211d2b597c10ee751f601320785d957443d61c8e5512d1c59df993febcf5ed94b8a71d
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --color
2
- --format progress
1
+ --color
2
+ --format progress
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --markup markdown
1
+ --markup markdown
data/README.md CHANGED
@@ -103,9 +103,15 @@ code coverage will also be generated
103
103
  [![Gem Version](https://badge.fury.io/rb/TimezoneParser.png)](http://badge.fury.io/rb/TimezoneParser)
104
104
  [![Build Status](https://travis-ci.org/davispuh/TimezoneParser.png?branch=master)](https://travis-ci.org/davispuh/TimezoneParser)
105
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)
106
+ [![Coverage Status](https://coveralls.io/repos/davispuh/TimezoneParser/badge.png?branch=master)](https://coveralls.io/r/davispuh/TimezoneParser?branch=master)
107
107
  [![Code Climate](https://codeclimate.com/github/davispuh/TimezoneParser.png)](https://codeclimate.com/github/davispuh/TimezoneParser)
108
108
 
109
+ ## Other
110
+
111
+ Did you found this library useful? Tell about it [![Tweet #2FTimezoneParser](http://i.imgur.com/ah3eSk3.png)](https://twitter.com/intent/tweet?hashtags=TimezoneParser&original_referer=https%3A%2F%2Fgithub.com%2Fdavispuh%2FTimezoneParser&related=davispuh&tw_p=tweetbutton&url=https%3A%2F%2Fgithub.com%2Fdavispuh%2FTimezoneParser)
112
+
113
+ You can also [![Flattr FTimezoneParser](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=davispuh&url=https%3A%2F%2Fgithub.com%2Fdavispuh%2FTimezoneParser&title=TimezoneParser&language=english&tags=github&category=software)
114
+
109
115
  ## Unlicense
110
116
 
111
117
  ![Copyright-Free](http://unlicense.org/pd-icon.png)
@@ -121,9 +127,10 @@ Feel free to improve as you see.
121
127
 
122
128
  1. Fork it
123
129
  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
130
+ 3. Export `.yml` data files to binary `.dat` with `rake export`
131
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
132
+ 5. Push to the branch (`git push origin my-new-feature`)
133
+ 6. Create new Pull Request
127
134
 
128
135
 
129
136
  **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)
data/Rakefile CHANGED
@@ -39,16 +39,21 @@ def update
39
39
  metazones = TimezoneParser::CLDR::getMetazones
40
40
  windowsZones = TimezoneParser::CLDR::getWindowsZones
41
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)
42
+ version = YAML.load_file(data_location + 'version.yml')
43
+ version['TZInfo'] = TimezoneParser::TZInfo::getVersion
44
+ version['CLDR'] = TimezoneParser::CLDR::getVersion
45
+ version['Rails'] = ActiveSupport::VERSION::STRING
46
+ version['WindowsZones'] = nil unless version.has_key?('WindowsZones')
47
+ options = { :cr_newline => false, :encoding => 'UTF-8:UTF-8' }
48
+ File.write(data_location + 'countries.yml', countries.to_yaml, options)
49
+ File.write(data_location + 'timezones.yml', timezones.to_yaml, options)
50
+ File.write(data_location + 'metazones.yml', metazones.to_yaml, options)
51
+ File.write(data_location + 'windows_timezones.yml', windowsZones.to_yaml, options)
47
52
  abbreviations = Hash[abbreviations.to_a.sort_by { |d| d.first } ]
48
- File.write(data_location + 'abbreviations.yml', abbreviations.to_yaml)
53
+ File.write(data_location + 'abbreviations.yml', abbreviations.to_yaml, options)
49
54
  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)
55
+ File.write(data_location + 'rails.yml', rails.to_yaml, options)
56
+ File.write(data_location + 'version.yml', version.to_yaml, options)
52
57
  end
53
58
 
54
59
  def update_rails
@@ -61,24 +66,25 @@ def update_rails
61
66
  names[locale] = Hash[namesArray.sort_by { |d| d.first } ]
62
67
  end
63
68
  end
64
- File.write(data_location + 'rails_i18n.yml', names.to_yaml)
69
+ File.write(data_location + 'rails_i18n.yml', names.to_yaml, { :cr_newline => false, :encoding => 'UTF-8:UTF-8' })
65
70
  end
66
71
 
67
72
  def update_windows
68
73
  os = Gem::Platform.local.os
69
74
  if (os == 'mingw32' or os == 'mingw64')
70
75
  require 'timezone_parser/data/windows'
76
+ options = { :cr_newline => false, :encoding => 'UTF-8:UTF-8' }
71
77
  version = YAML.load_file(data_location + 'version.yml')
72
78
  version['WindowsZones'] = TimezoneParser::Windows.getVersion
73
79
  if version['WindowsZones'].nil?
74
80
  $stderr.puts TimezoneParser::Windows.errors
75
81
  else
76
82
  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)
83
+ File.write(data_location + 'windows_offsets.yml', timezones.to_yaml, options)
84
+ File.write(data_location + 'version.yml', version.to_yaml, options)
79
85
  end
80
86
  else
81
- puts 'Sorry, you must be running Windows'
87
+ puts 'Skipped Windows Zone update. Need to be run from Windows.'
82
88
  end
83
89
  end
84
90
 
@@ -86,12 +92,16 @@ def import_timezones
86
92
  require 'timezone_parser/data/windows'
87
93
  os = Gem::Platform.local.os
88
94
  if (os == 'mingw32' or os == 'mingw64')
95
+ unless File.exist?(vendor_location + 'tzres.yml')
96
+ puts 'File `tzres.yml` not found. Windows Zone name importing skipped.'
97
+ return
98
+ end
89
99
  metazones = YAML.load_file(vendor_location + 'tzres.yml')
90
100
  offsets = TimezoneParser::Windows.getMUIOffsets
91
101
  metazone_names = TimezoneParser::Windows.parseMetazones(metazones, offsets)
92
- File.write(data_location + 'windows_zonenames.yml', metazone_names.to_yaml)
102
+ File.write(data_location + 'windows_zonenames.yml', metazone_names.to_yaml, { :cr_newline => false, :encoding => 'UTF-8:UTF-8' })
93
103
  else
94
- puts 'Sorry, you must be running Windows'
104
+ puts 'Can\'t import Windows Zone names. Need to be run from Windows.'
95
105
  end
96
106
  end
97
107
 
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'tzinfo-data'
38
38
  spec.add_development_dependency 'ruby-cldr'
39
39
  spec.add_development_dependency 'activesupport'
40
+ spec.add_development_dependency 'rubyzip'
40
41
  end
data/data/version.yml CHANGED
@@ -1,5 +1,5 @@
1
- ---
2
- TZInfo: 2013i
3
- CLDR: 24
4
- Rails: 4.1.0.rc1
5
- WindowsZones: 7de0000
1
+ ---
2
+ TZInfo: 2014h
3
+ CLDR: 26
4
+ Rails: 4.1.6
5
+ WindowsZones: 7de0007
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  module TimezoneParser
3
3
  # Version
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -1,122 +1,122 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe TimezoneParser do
5
- describe TimezoneParser::Abbreviation do
6
- describe '#new' do
7
- it 'should be an instance of a Abbreviation class' do
8
- expect(TimezoneParser::Abbreviation.new('CET')).to be_an_instance_of TimezoneParser::Abbreviation
9
- end
10
- end
11
-
12
- describe '#isValid?' do
13
- it 'should be valid abbreviation' do
14
- expect(TimezoneParser::Abbreviation.new('CET').isValid?).to be_true
15
- end
16
-
17
- it 'should not be valid abbreviation' do
18
- expect(TimezoneParser::Abbreviation.new('LOL').isValid?).to be_false
19
- end
20
-
21
- it 'should be valid case-insensitive abbreviation' do
22
- expect(TimezoneParser::Abbreviation.new('Pst').isValid?).to be_true
23
- end
24
- end
25
-
26
- describe '#getOffsets' do
27
- it 'should return offsets for CET abbreviation' do
28
- expect(TimezoneParser::Abbreviation.new('CET').getOffsets).to eq([3600])
29
- end
30
-
31
- it 'should return offsets for WEZ abbreviation' do
32
- expect(TimezoneParser::Abbreviation.new('WEZ').getOffsets).to eq([0, 3600])
33
- end
34
-
35
- context 'before specified time' do
36
- it 'should return correct offsets for ADT' do
37
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-04-30T21:00:00+00:00')).getOffsets).to eq([-10800])
38
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-04-30T21:00:01+00:00')).getOffsets).to eq([-10800, 14400])
39
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-09-30T19:59:59+00:00')).getOffsets).to eq([-10800, 14400])
40
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-09-30T20:00:00+00:00')).getOffsets).to eq([-10800, 14400])
41
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1983-03-30T21:00:00+00:00'), DateTime.parse('1982-09-30T20:00:00+00:00')).getOffsets).to eq([-10800])
42
- end
43
- end
44
-
45
- context 'between specified time' do
46
- it 'should return correct offsets for SAST' do
47
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:00+00:00'), DateTime.parse('1943-03-20T23:00:00+00:00')).getOffsets).to eq([7200])
48
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:00+00:00'), DateTime.parse('1943-03-20T22:59:59+00:00')).getOffsets).to eq([7200, 10800])
49
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:01+00:00'), DateTime.parse('1943-03-20T23:00:00+00:00')).getOffsets).to eq([7200, 10800])
50
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:01+00:00'), DateTime.parse('1943-09-19T00:00:00+00:00')).getOffsets).to eq([7200, 10800])
51
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1944-03-18T23:00:00+00:00'), DateTime.parse('1944-03-18T22:59:59+00:00')).getOffsets).to eq([7200, 10800])
52
- expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.now, DateTime.parse('1944-03-18T23:00:00+00:00')).getOffsets).to eq([7200])
53
- end
54
- end
55
-
56
- context 'in specified region' do
57
- it 'should return correct offsets for ADT' do
58
- expect(TimezoneParser::Abbreviation.new('ADT').set([]).getOffsets).to eq([-10800])
59
- expect(TimezoneParser::Abbreviation.new('ADT').set(['IQ']).getOffsets).to eq([14400])
60
- expect(TimezoneParser::Abbreviation.new('ADT').set(['GL']).getOffsets).to eq([-10800])
61
- expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('2007-10-01T00:00:00+00:00')).set(['IQ', 'CA']).getOffsets).to eq([-10800, 14400])
62
- end
63
- end
64
-
65
- context 'with specified type' do
66
- it 'should return correct offsets for HAT' do
67
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil).getOffsets).to eq([-36000, -32400, -12600, -9000])
68
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil).getOffsets).to eq([-36000, -32400, -12600, -9000])
69
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil, :standard ).getOffsets).to eq([-36000, -12600])
70
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil, :daylight ).getOffsets).to eq([-32400, -9000])
71
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil, :standard ).getOffsets).to eq([-36000, -12600])
72
- expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil, :daylight ).getOffsets).to eq([-32400, -9000])
73
- end
74
- end
75
- end
76
-
77
- describe '#getTimezones' do
78
- it 'should return all timezones for KMT abbreviation' do
79
- expect(TimezoneParser::Abbreviation.new('KMT').getTimezones).to eq(['Europe/Kiev'])
80
- end
81
-
82
- context 'between specified time' do
83
- it 'should include correct timezones for EET' do
84
- expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1919-04-15T00:00:00+00:00'), DateTime.parse('1918-09-16T01:00:00+00:00')).getTimezones).to include('Asia/Beirut', 'Europe/Istanbul', 'Europe/Warsaw')
85
- expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1919-09-16T00:00:00+00:00'), DateTime.parse('1919-04-15T00:00:00+00:00')).getTimezones).to_not include('Europe/Warsaw')
86
- expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1985-04-19T21:00:00+00:00'), DateTime.parse('1978-10-14T21:00:00+00:00')).getTimezones).to_not include('Europe/Istanbul')
87
- end
88
- end
89
- end
90
-
91
- describe '#getMetazones' do
92
- it 'should return all metazones for HAT abbreviation' do
93
- expect(TimezoneParser::Abbreviation.new('HAT').getMetazones).to eq(['Hawaii_Aleutian', 'Newfoundland'])
94
- end
95
- end
96
-
97
- describe '.isValid?' do
98
- it 'should be valid abbreviation' do
99
- expect(TimezoneParser::Abbreviation::isValid?('WGT')).to be_true
100
- end
101
- end
102
-
103
- describe '.getOffsets' do
104
- it 'should return offsets for WGT abbreviation in GL region' do
105
- expect(TimezoneParser::Abbreviation::getOffsets('WGT', DateTime.now, nil, ['GL'])).to eq([-10800])
106
- end
107
- end
108
-
109
- describe '.getTimezones' do
110
- it 'should return timezones for WGT abbreviation' do
111
- expect(TimezoneParser::Abbreviation::getTimezones('WGT', DateTime.parse('1916-07-28T03:26:56+00:00'), DateTime.parse('1916-07-28T01:14:40+00:00'), ['GL'])).to eq(['America/Danmarkshavn'])
112
- end
113
- end
114
-
115
- describe '.getMetazones' do
116
- it 'should return metazones for HKT abbreviation' do
117
- expect(TimezoneParser::Abbreviation::getMetazones('HKT')).to eq(['Hong_Kong'])
118
- end
119
- end
120
-
121
- end
122
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TimezoneParser do
5
+ describe TimezoneParser::Abbreviation do
6
+ describe '#new' do
7
+ it 'should not raise error' do
8
+ expect { TimezoneParser::Abbreviation.new('CET') }.not_to raise_error
9
+ end
10
+ end
11
+
12
+ describe '#isValid?' do
13
+ it 'should be valid abbreviation' do
14
+ expect(TimezoneParser::Abbreviation.new('CET').isValid?).to be true
15
+ end
16
+
17
+ it 'should not be valid abbreviation' do
18
+ expect(TimezoneParser::Abbreviation.new('LOL').isValid?).to be false
19
+ end
20
+
21
+ it 'should be valid case-insensitive abbreviation' do
22
+ expect(TimezoneParser::Abbreviation.new('Pst').isValid?).to be true
23
+ end
24
+ end
25
+
26
+ describe '#getOffsets' do
27
+ it 'should return offsets for CET abbreviation' do
28
+ expect(TimezoneParser::Abbreviation.new('CET').getOffsets).to eq([3600])
29
+ end
30
+
31
+ it 'should return offsets for WEZ abbreviation' do
32
+ expect(TimezoneParser::Abbreviation.new('WEZ').getOffsets).to eq([0, 3600])
33
+ end
34
+
35
+ context 'before specified time' do
36
+ it 'should return correct offsets for ADT' do
37
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-04-30T21:00:00+00:00')).getOffsets).to eq([-10800])
38
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-04-30T21:00:01+00:00')).getOffsets).to eq([-10800, 14400])
39
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-09-30T19:59:59+00:00')).getOffsets).to eq([-10800, 14400])
40
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1982-09-30T20:00:00+00:00')).getOffsets).to eq([-10800, 14400])
41
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('1983-03-30T21:00:00+00:00'), DateTime.parse('1982-09-30T20:00:00+00:00')).getOffsets).to eq([-10800])
42
+ end
43
+ end
44
+
45
+ context 'between specified time' do
46
+ it 'should return correct offsets for SAST' do
47
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:00+00:00'), DateTime.parse('1943-03-20T23:00:00+00:00')).getOffsets).to eq([7200])
48
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:00+00:00'), DateTime.parse('1943-03-20T22:59:59+00:00')).getOffsets).to eq([7200, 10800])
49
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:01+00:00'), DateTime.parse('1943-03-20T23:00:00+00:00')).getOffsets).to eq([7200, 10800])
50
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1943-09-19T00:00:01+00:00'), DateTime.parse('1943-09-19T00:00:00+00:00')).getOffsets).to eq([7200, 10800])
51
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.parse('1944-03-18T23:00:00+00:00'), DateTime.parse('1944-03-18T22:59:59+00:00')).getOffsets).to eq([7200, 10800])
52
+ expect(TimezoneParser::Abbreviation.new('SAST').setTime(DateTime.now, DateTime.parse('1944-03-18T23:00:00+00:00')).getOffsets).to eq([7200])
53
+ end
54
+ end
55
+
56
+ context 'in specified region' do
57
+ it 'should return correct offsets for ADT' do
58
+ expect(TimezoneParser::Abbreviation.new('ADT').set([]).getOffsets).to eq([-10800])
59
+ expect(TimezoneParser::Abbreviation.new('ADT').set(['IQ']).getOffsets).to eq([14400])
60
+ expect(TimezoneParser::Abbreviation.new('ADT').set(['GL']).getOffsets).to eq([-10800])
61
+ expect(TimezoneParser::Abbreviation.new('ADT').setTime(DateTime.parse('2007-10-01T00:00:00+00:00')).set(['IQ', 'CA']).getOffsets).to eq([-10800, 14400])
62
+ end
63
+ end
64
+
65
+ context 'with specified type' do
66
+ it 'should return correct offsets for HAT' do
67
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil).getOffsets).to eq([-36000, -32400, -12600, -9000])
68
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil).getOffsets).to eq([-36000, -32400, -12600, -9000])
69
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil, :standard ).getOffsets).to eq([-36000, -12600])
70
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-02-05T10:00:00+00:00')).set(nil, :daylight ).getOffsets).to eq([-32400, -9000])
71
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil, :standard ).getOffsets).to eq([-36000, -12600])
72
+ expect(TimezoneParser::Abbreviation.new('HAT').setTime(DateTime.parse('2014-04-05T10:00:00+00:00')).set(nil, :daylight ).getOffsets).to eq([-32400, -9000])
73
+ end
74
+ end
75
+ end
76
+
77
+ describe '#getTimezones' do
78
+ it 'should return all timezones for KMT abbreviation' do
79
+ expect(TimezoneParser::Abbreviation.new('KMT').getTimezones).to eq(['Europe/Kiev'])
80
+ end
81
+
82
+ context 'between specified time' do
83
+ it 'should include correct timezones for EET' do
84
+ expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1919-04-15T00:00:00+00:00'), DateTime.parse('1918-09-16T01:00:00+00:00')).getTimezones).to include('Asia/Beirut', 'Europe/Istanbul', 'Europe/Warsaw')
85
+ expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1919-09-16T00:00:00+00:00'), DateTime.parse('1919-04-15T00:00:00+00:00')).getTimezones).to_not include('Europe/Warsaw')
86
+ expect(TimezoneParser::Abbreviation.new('EET').setTime(DateTime.parse('1985-04-19T21:00:00+00:00'), DateTime.parse('1978-10-14T21:00:00+00:00')).getTimezones).to_not include('Europe/Istanbul')
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '#getMetazones' do
92
+ it 'should return all metazones for HAT abbreviation' do
93
+ expect(TimezoneParser::Abbreviation.new('HAT').getMetazones).to eq(['Hawaii_Aleutian', 'Newfoundland'])
94
+ end
95
+ end
96
+
97
+ describe '.isValid?' do
98
+ it 'should be valid abbreviation' do
99
+ expect(TimezoneParser::Abbreviation::isValid?('WGT')).to be true
100
+ end
101
+ end
102
+
103
+ describe '.getOffsets' do
104
+ it 'should return offsets for WGT abbreviation in GL region' do
105
+ expect(TimezoneParser::Abbreviation::getOffsets('WGT', DateTime.now, nil, ['GL'])).to eq([-10800])
106
+ end
107
+ end
108
+
109
+ describe '.getTimezones' do
110
+ it 'should return timezones for WGT abbreviation' do
111
+ expect(TimezoneParser::Abbreviation::getTimezones('WGT', DateTime.parse('1916-07-28T03:26:56+00:00'), DateTime.parse('1916-07-28T01:14:40+00:00'), ['GL'])).to eq(['America/Danmarkshavn'])
112
+ end
113
+ end
114
+
115
+ describe '.getMetazones' do
116
+ it 'should return metazones for HKT abbreviation' do
117
+ expect(TimezoneParser::Abbreviation::getMetazones('HKT')).to eq(['Hong_Kong'])
118
+ end
119
+ end
120
+
121
+ end
122
+ end
@@ -1,84 +1,84 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe TimezoneParser do
5
- describe TimezoneParser::RailsZone do
6
- describe '#new' do
7
- it 'should be an instance of a RailsZone class' do
8
- expect(TimezoneParser::RailsZone.new('노보시비르스크')).to be_an_instance_of TimezoneParser::RailsZone
9
- end
10
- end
11
-
12
- describe '#isValid?' do
13
- it 'should be valid Rails zone' do
14
- expect(TimezoneParser::RailsZone.new('노보시비르스크').isValid?).to be_true
15
- end
16
-
17
- it 'should not be valid Rails zone in "ru" locale' do
18
- expect(TimezoneParser::RailsZone.new('노보시비르스크').set(['ru']).isValid?).to be_false
19
- end
20
-
21
- it 'should not be valid Rails zone' do
22
- expect(TimezoneParser::RailsZone.new('NotExisistinge').isValid?).to be_false
23
- end
24
- end
25
-
26
- describe '#getOffsets' do
27
- it 'should return all offsets for "Grönland"' do
28
- expect(TimezoneParser::RailsZone.new('Grönland').getOffsets).to eq([-10800, -7200])
29
- end
30
- end
31
-
32
- describe '#getTimezones' do
33
- it 'should return all timezones for "Centro-Oeste de África"' do
34
- expect(TimezoneParser::RailsZone.new('Centro-Oeste de África').getTimezones).to eq(['Africa/Algiers'])
35
- end
36
-
37
- it 'it should not find "Hawaii" in "es" locale' do
38
- expect(TimezoneParser::RailsZone.new('Hawaii').set(['es']).getTimezones).to be_empty
39
- end
40
-
41
- it 'should find timezones for "pt" locale' do
42
- expect(TimezoneParser::RailsZone.new('Hora do Pacífico (EUA e Canadá)').set(['pt']).getTimezones).to eq(['America/Los_Angeles'])
43
- end
44
-
45
- end
46
-
47
- describe '#getZone' do
48
- it 'should return zone name' do
49
- expect(TimezoneParser::RailsZone.new('Североамериканское атлантическое время').getZone).to eq('Atlantic Time (Canada)')
50
- end
51
- end
52
-
53
- describe '.isValid?' do
54
- it 'should be valid Rails zone' do
55
- expect(TimezoneParser::RailsZone::isValid?('La Paz', ['en'])).to be_true
56
- end
57
- end
58
-
59
- describe '.getOffsets' do
60
- it 'should return all offsets for "Nuku\'alofa"' do
61
- expect(TimezoneParser::RailsZone::getOffsets('Nuku\'alofa', DateTime.now, nil, ['en', 'ru'], true)).to eq([46800])
62
- end
63
- end
64
-
65
- describe '.getTimezones' do
66
- it 'should find timezones' do
67
- expect(TimezoneParser::RailsZone::getTimezones('치와와', [], true)).to eq(['America/Chihuahua'])
68
- end
69
- end
70
-
71
- describe '.getMetazones' do
72
- it 'should return zone names' do
73
- expect(TimezoneParser::RailsZone::getMetazones('치와와')).to eq(['Chihuahua'])
74
- end
75
- end
76
-
77
- describe '.getZone' do
78
- it 'should return zone name' do
79
- expect(TimezoneParser::RailsZone::getZone('치와와')).to eq('Chihuahua')
80
- end
81
- end
82
-
83
- end
84
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TimezoneParser do
5
+ describe TimezoneParser::RailsZone do
6
+ describe '#new' do
7
+ it 'should not raise error' do
8
+ expect { TimezoneParser::RailsZone.new('노보시비르스크') }.not_to raise_error
9
+ end
10
+ end
11
+
12
+ describe '#isValid?' do
13
+ it 'should be valid Rails zone' do
14
+ expect(TimezoneParser::RailsZone.new('노보시비르스크').isValid?).to be true
15
+ end
16
+
17
+ it 'should not be valid Rails zone in "ru" locale' do
18
+ expect(TimezoneParser::RailsZone.new('노보시비르스크').set(['ru']).isValid?).to be false
19
+ end
20
+
21
+ it 'should not be valid Rails zone' do
22
+ expect(TimezoneParser::RailsZone.new('NotExisistinge').isValid?).to be false
23
+ end
24
+ end
25
+
26
+ describe '#getOffsets' do
27
+ it 'should return all offsets for "Grönland"' do
28
+ expect(TimezoneParser::RailsZone.new('Grönland').getOffsets).to eq([-10800, -7200])
29
+ end
30
+ end
31
+
32
+ describe '#getTimezones' do
33
+ it 'should return all timezones for "Centro-Oeste de África"' do
34
+ expect(TimezoneParser::RailsZone.new('Centro-Oeste de África').getTimezones).to eq(['Africa/Algiers'])
35
+ end
36
+
37
+ it 'it should not find "Hawaii" in "es" locale' do
38
+ expect(TimezoneParser::RailsZone.new('Hawaii').set(['es']).getTimezones).to be_empty
39
+ end
40
+
41
+ it 'should find timezones for "pt" locale' do
42
+ expect(TimezoneParser::RailsZone.new('Hora do Pacífico (EUA e Canadá)').set(['pt']).getTimezones).to eq(['America/Los_Angeles'])
43
+ end
44
+
45
+ end
46
+
47
+ describe '#getZone' do
48
+ it 'should return zone name' do
49
+ expect(TimezoneParser::RailsZone.new('Североамериканское атлантическое время').getZone).to eq('Atlantic Time (Canada)')
50
+ end
51
+ end
52
+
53
+ describe '.isValid?' do
54
+ it 'should be valid Rails zone' do
55
+ expect(TimezoneParser::RailsZone::isValid?('La Paz', ['en'])).to be true
56
+ end
57
+ end
58
+
59
+ describe '.getOffsets' do
60
+ it 'should return all offsets for "Nuku\'alofa"' do
61
+ expect(TimezoneParser::RailsZone::getOffsets('Nuku\'alofa', DateTime.now, nil, ['en', 'ru'], true)).to eq([46800])
62
+ end
63
+ end
64
+
65
+ describe '.getTimezones' do
66
+ it 'should find timezones' do
67
+ expect(TimezoneParser::RailsZone::getTimezones('치와와', [], true)).to eq(['America/Chihuahua'])
68
+ end
69
+ end
70
+
71
+ describe '.getMetazones' do
72
+ it 'should return zone names' do
73
+ expect(TimezoneParser::RailsZone::getMetazones('치와와')).to eq(['Chihuahua'])
74
+ end
75
+ end
76
+
77
+ describe '.getZone' do
78
+ it 'should return zone name' do
79
+ expect(TimezoneParser::RailsZone::getZone('치와와')).to eq('Chihuahua')
80
+ end
81
+ end
82
+
83
+ end
84
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,17 @@
1
- # encoding: utf-8
2
- require 'simplecov'
3
-
4
- if ENV['CI']
5
- require 'coveralls'
6
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
7
- end
8
-
9
- SimpleCov.start
10
-
11
- RSpec.configure do |config|
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
14
- end
15
- end
16
-
17
- require_relative '../lib/timezone_parser.rb'
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+
4
+ if ENV['CI']
5
+ require 'coveralls'
6
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
7
+ end
8
+
9
+ SimpleCov.start
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
16
+
17
+ require_relative '../lib/timezone_parser.rb'
@@ -1,76 +1,76 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe TimezoneParser do
5
- describe '.preload' do
6
- it 'should preload data files' do
7
- expect(TimezoneParser.preload).to be_true
8
- end
9
- end
10
-
11
- describe '.isValid?' do
12
- it 'should be valid timezone abbreviation' do
13
- expect(TimezoneParser.isValid?('HAP')).to be_true
14
- end
15
-
16
- it 'should be valid timezone name' do
17
- expect(TimezoneParser.isValid?('גיברלטר', ['he'])).to be_true
18
- end
19
-
20
- it 'should be valid Windows timezone name' do
21
- expect(TimezoneParser.isValid?('Θερινή ώρα Μαλαϊκής χερσονήσου', ['el-GR'])).to be_true
22
- end
23
-
24
- it 'should be valid Rails zone name' do
25
- expect(TimezoneParser.isValid?('ブエノスアイレス', ['ja'])).to be_true
26
- end
27
-
28
- it 'should not be valid' do
29
- expect(TimezoneParser.isValid?('blah')).to be_false
30
- end
31
- end
32
-
33
- describe '.getOffsets' do
34
- it 'should find offsets for timezone abbreviation' do
35
- expect(TimezoneParser.getOffsets('HAP', nil, nil, ['CA'])).to eq([-25200])
36
- end
37
-
38
- it 'should find offsets for timezone name' do
39
- expect(TimezoneParser.getOffsets('גיברלטר', nil, nil, ['GI'], ['he'])).to eq([3600, 7200])
40
- end
41
-
42
- it 'should find offsets for Windows timezone name' do
43
- expect(TimezoneParser.getOffsets('Θερινή ώρα Μαλαϊκής χερσονήσου', nil, nil, nil, ['el-GR'])).to eq([32400])
44
- end
45
-
46
- it 'should find offsets for Rails zone name' do
47
- expect(TimezoneParser.getOffsets('ブエノスアイレス', nil, nil, ['AR'], ['ja'])).to eq([-10800])
48
- end
49
-
50
- it 'should not find any offsets' do
51
- expect(TimezoneParser.getOffsets('blah')).to eq([])
52
- end
53
- end
54
-
55
- describe '.getTimezones' do
56
- it 'should find timezones for timezone abbreviation' do
57
- expect(TimezoneParser.getTimezones('HAP', nil, nil, ['CA'])).to eq(['America/Dawson', 'America/Vancouver', 'America/Whitehorse'])
58
- end
59
-
60
- it 'should find timezones for timezone name' do
61
- expect(TimezoneParser.getTimezones('גיברלטר', nil, nil, ['GI'], ['he'])).to eq(['Europe/Gibraltar'])
62
- end
63
-
64
- it 'should find timezones for Windows timezone name' do
65
- expect(TimezoneParser.getTimezones('Θερινή ώρα Μαλαϊκής χερσονήσου', nil, nil, nil, ['el-GR'])).to eq(['Asia/Brunei', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Asia/Makassar', 'Asia/Manila', 'Asia/Singapore', 'Etc/GMT-8'])
66
- end
67
-
68
- it 'should find timezones for Rails zone name' do
69
- expect(TimezoneParser.getTimezones('ブエノスアイレス', nil, nil, ['AR'], ['ja'])).to eq(['America/Argentina/Buenos_Aires', 'America/Buenos_Aires'])
70
- end
71
-
72
- it 'should not find any timezones' do
73
- expect(TimezoneParser.getTimezones('blah')).to eq([])
74
- end
75
- end
76
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TimezoneParser do
5
+ describe '.preload' do
6
+ it 'should preload data files' do
7
+ expect(TimezoneParser.preload).to be true
8
+ end
9
+ end
10
+
11
+ describe '.isValid?' do
12
+ it 'should be valid timezone abbreviation' do
13
+ expect(TimezoneParser.isValid?('HAP')).to be true
14
+ end
15
+
16
+ it 'should be valid timezone name' do
17
+ expect(TimezoneParser.isValid?('גיברלטר', ['he'])).to be true
18
+ end
19
+
20
+ it 'should be valid Windows timezone name' do
21
+ expect(TimezoneParser.isValid?('Θερινή ώρα Μαλαϊκής χερσονήσου', ['el-GR'])).to be true
22
+ end
23
+
24
+ it 'should be valid Rails zone name' do
25
+ expect(TimezoneParser.isValid?('ブエノスアイレス', ['ja'])).to be true
26
+ end
27
+
28
+ it 'should not be valid' do
29
+ expect(TimezoneParser.isValid?('blah')).to be false
30
+ end
31
+ end
32
+
33
+ describe '.getOffsets' do
34
+ it 'should find offsets for timezone abbreviation' do
35
+ expect(TimezoneParser.getOffsets('HAP', nil, nil, ['CA'])).to eq([-25200])
36
+ end
37
+
38
+ it 'should find offsets for timezone name' do
39
+ expect(TimezoneParser.getOffsets('גיברלטר', nil, nil, ['GI'], ['he'])).to eq([3600, 7200])
40
+ end
41
+
42
+ it 'should find offsets for Windows timezone name' do
43
+ expect(TimezoneParser.getOffsets('Θερινή ώρα Μαλαϊκής χερσονήσου', nil, nil, nil, ['el-GR'])).to eq([32400])
44
+ end
45
+
46
+ it 'should find offsets for Rails zone name' do
47
+ expect(TimezoneParser.getOffsets('ブエノスアイレス', nil, nil, ['AR'], ['ja'])).to eq([-10800])
48
+ end
49
+
50
+ it 'should not find any offsets' do
51
+ expect(TimezoneParser.getOffsets('blah')).to eq([])
52
+ end
53
+ end
54
+
55
+ describe '.getTimezones' do
56
+ it 'should find timezones for timezone abbreviation' do
57
+ expect(TimezoneParser.getTimezones('HAP', nil, nil, ['CA'])).to eq(['America/Dawson', 'America/Vancouver', 'America/Whitehorse'])
58
+ end
59
+
60
+ it 'should find timezones for timezone name' do
61
+ expect(TimezoneParser.getTimezones('גיברלטר', nil, nil, ['GI'], ['he'])).to eq(['Europe/Gibraltar'])
62
+ end
63
+
64
+ it 'should find timezones for Windows timezone name' do
65
+ expect(TimezoneParser.getTimezones('Θερινή ώρα Μαλαϊκής χερσονήσου', nil, nil, nil, ['el-GR'])).to eq(['Asia/Brunei', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Asia/Makassar', 'Asia/Manila', 'Asia/Singapore', 'Etc/GMT-8'])
66
+ end
67
+
68
+ it 'should find timezones for Rails zone name' do
69
+ expect(TimezoneParser.getTimezones('ブエノスアイレス', nil, nil, ['AR'], ['ja'])).to eq(['America/Argentina/Buenos_Aires', 'America/Buenos_Aires'])
70
+ end
71
+
72
+ it 'should not find any timezones' do
73
+ expect(TimezoneParser.getTimezones('blah')).to eq([])
74
+ end
75
+ end
76
+ end
@@ -1,108 +1,108 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe TimezoneParser do
5
- describe TimezoneParser::Timezone do
6
- describe '#new' do
7
- it 'should be an instance of a Timezone class' do
8
- expect(TimezoneParser::Timezone.new('Argentinische Normalzeit')).to be_an_instance_of TimezoneParser::Timezone
9
- end
10
- end
11
-
12
- describe '#isValid?' do
13
- it 'should be valid timezone' do
14
- expect(TimezoneParser::Timezone.new('Argentinische Normalzeit').isValid?).to be_true
15
- end
16
-
17
- it 'should not be valid timezone' do
18
- expect(TimezoneParser::Timezone.new('Random place').isValid?).to be_false
19
- end
20
-
21
- it 'should be valid case-insensitive' do
22
- expect(TimezoneParser::Timezone.new('büsingen').isValid?).to be_true
23
- pending('TODO: Unicode case insensitivity')
24
- expect(TimezoneParser::Timezone.new('bÜsingen').isValid?).to be_true
25
- end
26
- end
27
-
28
- describe '#getOffsets' do
29
- it 'should return all offsets for "Պարսկաստանի ամառային ժամանակ"' do
30
- expect(TimezoneParser::Timezone.new('Պարսկաստանի ամառային ժամանակ').getOffsets).to eq([16200])
31
- end
32
- end
33
-
34
- describe '#getTimezones' do
35
- it 'should return all timezones for "Bécs"' do
36
- expect(TimezoneParser::Timezone.new('Bécs').getTimezones).to eq(['Europe/Vienna'])
37
- end
38
-
39
- context 'timezones from specified locales' do
40
- it 'should find timezones for only "zh" locale' do
41
- expect(TimezoneParser::Timezone.new('阿尤恩').set(['zh']).getTimezones).to eq(['Africa/El_Aaiun'])
42
- end
43
-
44
- it 'should find timezones for "en_Dsrt" locale' do
45
- expect(TimezoneParser::Timezone.new('𐐁𐑍𐐿𐐲𐑉𐐮𐐾').set(['en_Dsrt']).getTimezones).to eq(['America/Anchorage'])
46
- end
47
-
48
- it 'it should not find "China Summer Time" in "en" locale' do
49
- expect(TimezoneParser::Timezone.new('China Summer Time').set(['en']).getTimezones).to be_empty
50
- end
51
- end
52
-
53
- context 'timezones from specified regions' do
54
- it 'should find timezones in only "LT" region' do
55
- expect(TimezoneParser::Timezone.new('ເວລາເອີຣົບຕາເວັນອອກ').set(nil, ['LT']).getTimezones).to eq(['Europe/Vilnius'])
56
- end
57
-
58
- it 'should find timezones in only "GR", "FI" and "BG" regions' do
59
- expect(TimezoneParser::Timezone.new('ເວລາເອີຣົບຕາເວັນອອກ').set(nil, ['GR', 'FI', 'BG']).getTimezones).to eq(['Europe/Athens', 'Europe/Helsinki', 'Europe/Sofia'])
60
- end
61
- end
62
-
63
- context 'timezones from specified time range' do
64
- it 'should find timezones between specified time range' do
65
- expect(TimezoneParser::Timezone.new('Maskvos laikas').setTime(DateTime.parse('1992-01-19T00:00:00+00:00'), DateTime.parse('1991-03-30T23:00:00+00:00')).getTimezones).to eq(['Europe/Kaliningrad', 'Europe/Minsk', 'Europe/Moscow', 'Europe/Vilnius', 'Europe/Zaporozhye'])
66
- expect(TimezoneParser::Timezone.new('Maskvos laikas').setTime(DateTime.parse('2010-03-27T22:00:00+00:00'), DateTime.parse('1992-01-19T00:00:00+00:00')).getTimezones).to eq(['Europe/Moscow', 'Europe/Simferopol'])
67
- end
68
- end
69
- end
70
-
71
- describe '#getMetazones' do
72
- it 'should return all metazones for "Nord-Marianene-tid"' do
73
- expect(TimezoneParser::Timezone.new('Nord-Marianene-tid').getMetazones).to eq(['North_Mariana'])
74
- end
75
- end
76
-
77
- describe '#getTypes' do
78
- it 'should return types for "Nord-Marianene-tid"' do
79
- expect(TimezoneParser::Timezone.new('Nord-Marianene-tid').getTypes).to eq([:standard])
80
- end
81
- end
82
-
83
- describe '.isValid?' do
84
- it 'should be valid timezone' do
85
- expect(TimezoneParser::Timezone::isValid?('பெட்ரோபவ்லோவ்ஸ்க் கம்சட்ஸ்கி நேரம்')).to be_true
86
- end
87
- end
88
-
89
- describe '.getOffsets' do
90
- it 'should find offsets for "सामोआ प्रमाण वेळ" zone and in "UM" region' do
91
- expect(TimezoneParser::Timezone::getOffsets('सामोआ प्रमाण वेळ', nil, nil, nil, ['UM'])).to eq([-39600])
92
- end
93
- end
94
-
95
- describe '.getTimezones' do
96
- it 'should return all timezones for "Grinwish gaƒoƒome"' do
97
- expect(TimezoneParser::Timezone::getTimezones('Grinwish gaƒoƒome', nil, nil, ['dz', 'ee'], ['IM'])).to eq(['Europe/Isle_of_Man'])
98
- end
99
- end
100
-
101
- describe '.getMetazones' do
102
- it 'should return all metazones for "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཆུ་ཚོད"' do
103
- expect(TimezoneParser::Timezone::getMetazones('ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཆུ་ཚོད')).to eq(['Greenland_Western'])
104
- end
105
- end
106
-
107
- end
108
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TimezoneParser do
5
+ describe TimezoneParser::Timezone do
6
+ describe '#new' do
7
+ it 'should not raise error' do
8
+ expect { TimezoneParser::Timezone.new('Argentinische Normalzeit') }.not_to raise_error
9
+ end
10
+ end
11
+
12
+ describe '#isValid?' do
13
+ it 'should be valid timezone' do
14
+ expect(TimezoneParser::Timezone.new('Argentinische Normalzeit').isValid?).to be true
15
+ end
16
+
17
+ it 'should not be valid timezone' do
18
+ expect(TimezoneParser::Timezone.new('Random place').isValid?).to be false
19
+ end
20
+
21
+ it 'should be valid case-insensitive' do
22
+ expect(TimezoneParser::Timezone.new('büsingen').isValid?).to be true
23
+ pending('TODO: Unicode case insensitivity')
24
+ expect(TimezoneParser::Timezone.new('bÜsingen').isValid?).to be true
25
+ end
26
+ end
27
+
28
+ describe '#getOffsets' do
29
+ it 'should return all offsets for "Պարսկաստանի ամառային ժամանակ"' do
30
+ expect(TimezoneParser::Timezone.new('Պարսկաստանի ամառային ժամանակ').getOffsets).to eq([16200])
31
+ end
32
+ end
33
+
34
+ describe '#getTimezones' do
35
+ it 'should return all timezones for "Bécs"' do
36
+ expect(TimezoneParser::Timezone.new('Bécs').getTimezones).to eq(['Europe/Vienna'])
37
+ end
38
+
39
+ context 'timezones from specified locales' do
40
+ it 'should find timezones for only "zh" locale' do
41
+ expect(TimezoneParser::Timezone.new('阿尤恩').set(['zh']).getTimezones).to eq(['Africa/El_Aaiun'])
42
+ end
43
+
44
+ it 'should find timezones for "ka" locale' do
45
+ expect(TimezoneParser::Timezone.new('ენქორაჯი').set(['ka']).getTimezones).to eq(['America/Anchorage'])
46
+ end
47
+
48
+ it 'it should not find "China Summer Time" in "en" locale' do
49
+ expect(TimezoneParser::Timezone.new('China Summer Time').set(['en']).getTimezones).to be_empty
50
+ end
51
+ end
52
+
53
+ context 'timezones from specified regions' do
54
+ it 'should find timezones in only "LT" region' do
55
+ expect(TimezoneParser::Timezone.new('ვილნიუსი').set(nil, ['LT']).getTimezones).to eq(['Europe/Vilnius'])
56
+ end
57
+
58
+ it 'should find timezones in only "GR", "FI" and "BG" regions' do
59
+ expect(TimezoneParser::Timezone.new('აღმოსავლეთ ევროპის დრო').set(nil, ['GR', 'FI', 'BG']).getTimezones).to eq(['Europe/Athens', 'Europe/Helsinki', 'Europe/Sofia'])
60
+ end
61
+ end
62
+
63
+ context 'timezones from specified time range' do
64
+ it 'should find timezones between specified time range' do
65
+ expect(TimezoneParser::Timezone.new('Maskvos laikas').setTime(DateTime.parse('1991-03-30T23:00:00+00:00'), DateTime.parse('1990-06-30T23:00:00+00:00')).getTimezones).to eq(['Europe/Kaliningrad', 'Europe/Minsk', 'Europe/Moscow', 'Europe/Samara', 'Europe/Vilnius', 'Europe/Zaporozhye'])
66
+ expect(TimezoneParser::Timezone.new('Maskvos laikas').setTime(DateTime.parse('2010-03-27T22:00:00+00:00'), DateTime.parse('1997-03-30T01:00:00+00:00')).getTimezones).to eq(['Europe/Moscow', 'Europe/Volgograd'])
67
+ end
68
+ end
69
+ end
70
+
71
+ describe '#getMetazones' do
72
+ it 'should return all metazones for "Nord-Marianene-tid"' do
73
+ expect(TimezoneParser::Timezone.new('Nord-Marianene-tid').getMetazones).to eq(['North_Mariana'])
74
+ end
75
+ end
76
+
77
+ describe '#getTypes' do
78
+ it 'should return types for "Nord-Marianene-tid"' do
79
+ expect(TimezoneParser::Timezone.new('Nord-Marianene-tid').getTypes).to eq([:standard])
80
+ end
81
+ end
82
+
83
+ describe '.isValid?' do
84
+ it 'should be valid timezone' do
85
+ expect(TimezoneParser::Timezone::isValid?('பெட்ரோபவ்லோவ்ஸ்க் கம்சட்ஸ்கி நேரம்')).to be true
86
+ end
87
+ end
88
+
89
+ describe '.getOffsets' do
90
+ it 'should find offsets for "सामोआ प्रमाण वेळ" zone and in "UM" region' do
91
+ expect(TimezoneParser::Timezone::getOffsets('सामोआ प्रमाण वेळ', nil, nil, nil, ['UM'])).to eq([-39600])
92
+ end
93
+ end
94
+
95
+ describe '.getTimezones' do
96
+ it 'should return all timezones for "Grinwish gaƒoƒome"' do
97
+ expect(TimezoneParser::Timezone::getTimezones('Grinwish gaƒoƒome', nil, nil, ['dz', 'ee'], ['IM'])).to eq(['Europe/London'])
98
+ end
99
+ end
100
+
101
+ describe '.getMetazones' do
102
+ it 'should return all metazones for "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཆུ་ཚོད"' do
103
+ expect(TimezoneParser::Timezone::getMetazones('ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཆུ་ཚོད')).to eq(['Greenland_Western'])
104
+ end
105
+ end
106
+
107
+ end
108
+ end
@@ -1,81 +1,81 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe TimezoneParser do
5
- describe TimezoneParser::WindowsZone do
6
- describe '#new' do
7
- it 'should be an instance of a WindowsZone class' do
8
- expect(TimezoneParser::WindowsZone.new('Azerbaijan Summer Time')).to be_an_instance_of TimezoneParser::WindowsZone
9
- end
10
- end
11
-
12
- describe '#isValid?' do
13
- it 'should be valid Windows zone' do
14
- expect(TimezoneParser::WindowsZone.new('Azerbaijan Summer Time').isValid?).to be_true
15
- end
16
-
17
- it 'should not be valid Windows zone' do
18
- expect(TimezoneParser::WindowsZone.new('NotExisistinge').isValid?).to be_false
19
- end
20
-
21
- end
22
-
23
- describe '#getOffsets' do
24
- it 'should return all offsets for "Severoázijský čas (normálny)"' do
25
- expect(TimezoneParser::WindowsZone.new('Severoázijský čas (normálny)').getOffsets).to eq([28800])
26
- end
27
- end
28
-
29
- describe '#getTimezones' do
30
- it 'should return all timezones for "كوريا - التوقيت الرسمي"' do
31
- expect(TimezoneParser::WindowsZone.new('كوريا - التوقيت الرسمي').getTimezones).to eq(['Asia/Pyongyang', 'Asia/Seoul'])
32
- end
33
-
34
- it 'it should not find "GMT Daylight Time" in "en-GB" locale' do
35
- expect(TimezoneParser::WindowsZone.new('GMT Daylight Time').set(['en-GB']).getTimezones).to be_empty
36
- end
37
-
38
- it 'should find timezones for "SR" region and in "sl-SI" locale' do
39
- expect(TimezoneParser::WindowsZone.new('Južnoameriški vzh. stand. čas').set(['sl-SI'], ['SR']).getTimezones).to eq(['America/Paramaribo'])
40
- end
41
-
42
- end
43
-
44
- describe '#getZone' do
45
- it 'should return zone name' do
46
- expect(TimezoneParser::WindowsZone.new('ora legale Medioatlantico').getZone).to eq('Mid-Atlantic Standard Time')
47
- end
48
- end
49
-
50
- describe '.isValid?' do
51
- it 'should be valid Windows zone' do
52
- expect(TimezoneParser::WindowsZone::isValid?('Ekaterinburg, oră standard', ['ro-RO'])).to be_true
53
- end
54
- end
55
-
56
- describe '.getOffsets' do
57
- it 'should return all offsets for "Sør-Amerika (østlig sommertid)"' do
58
- expect(TimezoneParser::WindowsZone::getOffsets('Sør-Amerika (østlig sommertid)', ['lt-LT', 'nb-NO'])).to eq([-7200])
59
- end
60
- end
61
-
62
- describe '.getTimezones' do
63
- it 'should find timezones for "Južnoafriški poletni čas"' do
64
- expect(TimezoneParser::WindowsZone::getTimezones('Južnoafriški poletni čas', nil, ['MW', 'MZ'])).to eq(['Africa/Blantyre', 'Africa/Maputo'])
65
- end
66
- end
67
-
68
- describe '.getMetazones' do
69
- it 'should find metazones for "Južnoafriški poletni čas"' do
70
- expect(TimezoneParser::WindowsZone::getMetazones('Južnoafriški poletni čas')).to eq(['South Africa Standard Time'])
71
- end
72
- end
73
-
74
- describe '.getZone' do
75
- it 'should return zone name' do
76
- expect(TimezoneParser::WindowsZone::getZone('Južnoafriški poletni čas')).to eq('South Africa Standard Time')
77
- end
78
- end
79
-
80
- end
81
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TimezoneParser do
5
+ describe TimezoneParser::WindowsZone do
6
+ describe '#new' do
7
+ it 'should not raise error' do
8
+ expect { TimezoneParser::WindowsZone.new('Azerbaijan Summer Time') }.not_to raise_error
9
+ end
10
+ end
11
+
12
+ describe '#isValid?' do
13
+ it 'should be valid Windows zone' do
14
+ expect(TimezoneParser::WindowsZone.new('Azerbaijan Summer Time').isValid?).to be true
15
+ end
16
+
17
+ it 'should not be valid Windows zone' do
18
+ expect(TimezoneParser::WindowsZone.new('NotExisistinge').isValid?).to be false
19
+ end
20
+
21
+ end
22
+
23
+ describe '#getOffsets' do
24
+ it 'should return all offsets for "Severoázijský čas (normálny)"' do
25
+ expect(TimezoneParser::WindowsZone.new('Severoázijský čas (normálny)').getOffsets).to eq([25200])
26
+ end
27
+ end
28
+
29
+ describe '#getTimezones' do
30
+ it 'should return all timezones for "كوريا - التوقيت الرسمي"' do
31
+ expect(TimezoneParser::WindowsZone.new('كوريا - التوقيت الرسمي').getTimezones).to eq(['Asia/Pyongyang', 'Asia/Seoul'])
32
+ end
33
+
34
+ it 'it should not find "GMT Daylight Time" in "en-GB" locale' do
35
+ expect(TimezoneParser::WindowsZone.new('GMT Daylight Time').set(['en-GB']).getTimezones).to be_empty
36
+ end
37
+
38
+ it 'should find timezones for "SR" region and in "sl-SI" locale' do
39
+ expect(TimezoneParser::WindowsZone.new('Južnoameriški vzh. stand. čas').set(['sl-SI'], ['SR']).getTimezones).to eq(['America/Paramaribo'])
40
+ end
41
+
42
+ end
43
+
44
+ describe '#getZone' do
45
+ it 'should return zone name' do
46
+ expect(TimezoneParser::WindowsZone.new('ora legale Medioatlantico').getZone).to eq('Mid-Atlantic Standard Time')
47
+ end
48
+ end
49
+
50
+ describe '.isValid?' do
51
+ it 'should be valid Windows zone' do
52
+ expect(TimezoneParser::WindowsZone::isValid?('Ekaterinburg, oră standard', ['ro-RO'])).to be true
53
+ end
54
+ end
55
+
56
+ describe '.getOffsets' do
57
+ it 'should return all offsets for "Sør-Amerika (østlig sommertid)"' do
58
+ expect(TimezoneParser::WindowsZone::getOffsets('Sør-Amerika (østlig sommertid)', ['lt-LT', 'nb-NO'])).to eq([-7200])
59
+ end
60
+ end
61
+
62
+ describe '.getTimezones' do
63
+ it 'should find timezones for "Južnoafriški poletni čas"' do
64
+ expect(TimezoneParser::WindowsZone::getTimezones('Južnoafriški poletni čas', nil, ['MW', 'MZ'])).to eq(['Africa/Blantyre', 'Africa/Maputo'])
65
+ end
66
+ end
67
+
68
+ describe '.getMetazones' do
69
+ it 'should find metazones for "Južnoafriški poletni čas"' do
70
+ expect(TimezoneParser::WindowsZone::getMetazones('Južnoafriški poletni čas')).to eq(['South Africa Standard Time'])
71
+ end
72
+ end
73
+
74
+ describe '.getZone' do
75
+ it 'should return zone name' do
76
+ expect(TimezoneParser::WindowsZone::getZone('Južnoafriški poletni čas')).to eq('South Africa Standard Time')
77
+ end
78
+ end
79
+
80
+ end
81
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TimezoneParser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dāvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubyzip
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description: Library for parsing Timezone names and abbrevations to corresponding
154
168
  UTC offsets and much more
155
169
  email:
@@ -214,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
228
  version: '0'
215
229
  requirements: []
216
230
  rubyforge_project:
217
- rubygems_version: 2.2.1
231
+ rubygems_version: 2.4.1
218
232
  signing_key:
219
233
  specification_version: 4
220
234
  summary: Parse Timezone names written in any language to offsets and TimeZone identifiers