worldtimeengine 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -52,7 +52,7 @@ gem 'worldtimeengine'
52
52
  response.time.zone.current.description
53
53
  => "Central European Summer Time"
54
54
  response.time.zone.current.utc_offset
55
- => '+2:00'
55
+ => '+02:00'
56
56
  response.time.zone.current.is_dst
57
57
  => true
58
58
  response.time.zone.current.effective_until
@@ -63,7 +63,7 @@ gem 'worldtimeengine'
63
63
  response.time.zone.next.description
64
64
  => "Central European Time"
65
65
  response.time.zone.next.utc_offset
66
- => "+1:00"
66
+ => "+01:00"
67
67
  response.time.zone.next.is_dst
68
68
  => false
69
69
  response.time.zone.next.effective_until
@@ -51,7 +51,8 @@ module WorldTimeEngine
51
51
  mash.time.zone.has_dst = to_boolean mash.time.zone.hasDST
52
52
 
53
53
  mash.time.zone.current.is_dst = to_boolean mash.time.zone.current.isdst
54
- mash.time.zone.current.utc_offset = mash.time.zone.current.utcoffset
54
+
55
+ mash.time.zone.current.utc_offset = to_formatted_offset mash.time.zone.current.utcoffset
55
56
 
56
57
  # could be missing for not recognized IPs
57
58
  unless mash.time.zone.current.effectiveUntil.nil?
@@ -60,7 +61,7 @@ module WorldTimeEngine
60
61
 
61
62
  if mash.time.zone.has_dst
62
63
  mash.time.zone.next.is_dst = to_boolean mash.time.zone.next.isdst
63
- mash.time.zone.next.utc_offset = mash.time.zone.next.utcoffset
64
+ mash.time.zone.next.utc_offset = to_formatted_offset mash.time.zone.next.utcoffset
64
65
  mash.time.zone.next.effective_until = Time.parse "#{mash.time.zone.next.effectiveUntil} #{mash.time.zone.next.abbreviation} #{mash.time.zone.next.utcoffset}"
65
66
  end
66
67
  end
@@ -68,6 +69,16 @@ module WorldTimeEngine
68
69
 
69
70
  private
70
71
 
72
+ def to_formatted_offset(string)
73
+ return if string.nil?
74
+
75
+ if string.split(':').first.length == '+1'.length
76
+ string.gsub!('-', '-0')
77
+ string.gsub!('+', '+0')
78
+ end
79
+ string
80
+ end
81
+
71
82
  def to_time(string)
72
83
  Time.parse string
73
84
  end
@@ -106,13 +106,13 @@ describe WorldTimeEngine do
106
106
  response.time.zone.has_dst.should == true
107
107
  response.time.zone.current.abbreviation.should == "CEST"
108
108
  response.time.zone.current.description.should == "Central European Summer Time"
109
- response.time.zone.current.utc_offset.should == '+2:00'
109
+ response.time.zone.current.utc_offset.should == '+02:00'
110
110
  response.time.zone.current.is_dst.should == true
111
111
  response.time.zone.current.effective_until.should == Time.parse("2012-10-28 03:00:00")
112
112
 
113
113
  response.time.zone.next.abbreviation.should == 'CET'
114
114
  response.time.zone.next.description.should == "Central European Time"
115
- response.time.zone.next.utc_offset.should == "+1:00"
115
+ response.time.zone.next.utc_offset.should == "+01:00"
116
116
  response.time.zone.next.is_dst.should == false
117
117
  response.time.zone.next.effective_until.should == Time.parse("2013-03-31 02:00:00")
118
118
  end
@@ -19,6 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
20
20
  gem.summary = %q{WorldTimeEngine API wrapper}
21
21
  gem.test_files = Dir.glob("spec/**/*")
22
- gem.version = '0.0.3'
22
+ gem.version = '0.0.4'
23
23
  end
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldtimeengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: 206980578948058900
146
+ hash: -999268238348806578
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements: