TimezoneParser 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad1e481a9230be8371756904933dded13a0483f7
4
- data.tar.gz: b602468cb7d2e28e8bf69c427eee8bfbaa4d9889
3
+ metadata.gz: 801e797d854babedd580bcf96aa98356e03e4923
4
+ data.tar.gz: d5d0f47184e279fd7628fe292c24778b8e044927
5
5
  SHA512:
6
- metadata.gz: a0588231219e5c9c8303dd0e920f9cc2b493ffe49c16d33a60f6dc3639af715e71ceefdcb7019653b5ceb05bb5b3a9a72b517cc3a1174d1a4dbe1ae9f4945f6c
7
- data.tar.gz: ad395662299d90987b17e04682a93a6505d0abb2f993b775a8f0beecca211d2b597c10ee751f601320785d957443d61c8e5512d1c59df993febcf5ed94b8a71d
6
+ metadata.gz: 913e2b9eb391a6fdf900f0645f12914b39b68d819c6f89adff62d2bae24abaf278cebe6405ff23f2f08eb973b372f0d739929047209c215b443978d44d9dc094
7
+ data.tar.gz: 1bb4c8dba1a94a09eae70416a7e7149d1123ab47571df2d03745e251394f402e51d496d05ab854786f24affb9751db7182290c66987c9a4e9a3875db7e60e618
@@ -80,13 +80,23 @@ module TimezoneParser
80
80
  @Offsets
81
81
  end
82
82
 
83
- # Check if given Timezone abbreviation is a valid timezone
83
+ # Check if given Timezone abbreviation (case-sensitive) is a valid timezone
84
84
  # @param abbreviation [String] Timezone abbreviation
85
85
  # @return [Boolean] whether Timezone is valid
86
86
  def self.isValid?(abbreviation)
87
87
  Data::Storage.Abbreviations.has_key?(abbreviation)
88
88
  end
89
89
 
90
+ # Check if given Timezone abbreviation (case-insensitive) could be a valid timezone
91
+ # @param abbreviation [String] Timezone abbreviation to check for
92
+ # @return [Boolean] whether Timezone is valid
93
+ def self.couldBeValid?(abbreviation)
94
+ Data::Storage.Abbreviations.each_key do |abbr|
95
+ return true if abbr.casecmp(abbreviation).zero?
96
+ end
97
+ false
98
+ end
99
+
90
100
  # Get UTC offsets in seconds for given Timezone abbreviation
91
101
  # @param abbreviation [String] Timezone abbreviation
92
102
  # @param toTime [DateTime] look for offsets which came into effect before this date, exclusive
@@ -21,7 +21,7 @@ module TimezoneParser
21
21
  public
22
22
  def self.Abbreviations
23
23
  unless @@Abbreviations
24
- @@Abbreviations = Marshal.load(File.open(Data::DataDir + 'abbreviations.dat')).insensitive
24
+ @@Abbreviations = Marshal.load(File.open(Data::DataDir + 'abbreviations.dat'))
25
25
  @@Abbreviations.each do |abbr, data|
26
26
  proccessData(data)
27
27
  end
@@ -45,7 +45,7 @@ module TimezoneParser
45
45
 
46
46
  def self.Metazones
47
47
  unless @@Metazones
48
- @@Metazones = Marshal.load(File.open(Data::DataDir + 'metazones.dat')).insensitive
48
+ @@Metazones = Marshal.load(File.open(Data::DataDir + 'metazones.dat'))
49
49
  @@Metazones.each do |zone, data|
50
50
  proccessData(data)
51
51
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  module TimezoneParser
3
3
  # Version
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -18,8 +18,8 @@ describe TimezoneParser do
18
18
  expect(TimezoneParser::Abbreviation.new('LOL').isValid?).to be false
19
19
  end
20
20
 
21
- it 'should be valid case-insensitive abbreviation' do
22
- expect(TimezoneParser::Abbreviation.new('Pst').isValid?).to be true
21
+ it 'should be invalid case-insensitive abbreviation' do
22
+ expect(TimezoneParser::Abbreviation.new('Pst').isValid?).to be false
23
23
  end
24
24
  end
25
25
 
@@ -100,6 +100,20 @@ describe TimezoneParser do
100
100
  end
101
101
  end
102
102
 
103
+ describe '.couldBeValid?' do
104
+ it 'should be valid abbreviation' do
105
+ expect(TimezoneParser::Abbreviation.couldBeValid?('cet')).to be true
106
+ end
107
+
108
+ it 'should not be valid abbreviation' do
109
+ expect(TimezoneParser::Abbreviation.couldBeValid?('WZE')).to be false
110
+ end
111
+
112
+ it 'should be valid case-insensitive abbreviation' do
113
+ expect(TimezoneParser::Abbreviation.couldBeValid?('Pst')).to be true
114
+ end
115
+ end
116
+
103
117
  describe '.getOffsets' do
104
118
  it 'should return offsets for WGT abbreviation in GL region' do
105
119
  expect(TimezoneParser::Abbreviation::getOffsets('WGT', DateTime.now, nil, ['GL'])).to eq([-10800])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TimezoneParser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dāvis