hackapp_gem 0.2.0 → 0.2.1
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 +4 -4
- data/lib/hackapp_gem.rb +17 -7
- data/lib/hackapp_gem/version.rb +1 -1
- data/spec/lib/hackapp_gem_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6beb3ae222f109fb32e7c82a46e0e97145e88c5
|
|
4
|
+
data.tar.gz: d8b015c6ecaa0cd47d4c8d78bea5aa786bd8d0b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48c52a179edbc4c77c79b5273426ba7233580c3500cb7e0bbe92ff985ef2df2d132114cd11348136d07d2dad6fe578d39708ad683244a09cf7967ca8f9e36b08
|
|
7
|
+
data.tar.gz: 9db5c99a22326e0449519059fac6d9166fd7b3243d92da66bef1e4095af20f61edb2e022571263dcd1c6606299966b95d1bd59cc0743701c5f0f15ba103440a6
|
data/lib/hackapp_gem.rb
CHANGED
|
@@ -2,10 +2,12 @@ require "hackapp_gem/version"
|
|
|
2
2
|
|
|
3
3
|
module HackappGem
|
|
4
4
|
class ::Time
|
|
5
|
-
|
|
5
|
+
# times in database are eastern time to add 5 hours to all
|
|
6
6
|
def to_UTC
|
|
7
7
|
begin
|
|
8
|
-
|
|
8
|
+
shift_to_UTC = 5 if Time.new.zone == "EST"
|
|
9
|
+
shift_to_UTC = 4 if Time.new.zone == "EDT"
|
|
10
|
+
self.to_datetime.advance(:hours => shift_to_UTC).to_datetime
|
|
9
11
|
rescue Exception => e
|
|
10
12
|
puts "Unrecognizeable timezone: #{e}"
|
|
11
13
|
end
|
|
@@ -13,14 +15,23 @@ module HackappGem
|
|
|
13
15
|
|
|
14
16
|
# adjust according to what you want to view
|
|
15
17
|
def change_timezone(options)
|
|
16
|
-
zones = {"eastern" => -
|
|
17
|
-
"central" => -
|
|
18
|
-
"mountain" => -
|
|
18
|
+
zones = {"eastern" => -5,
|
|
19
|
+
"central" => -6,
|
|
20
|
+
"mountain" => -7,
|
|
19
21
|
"arizona" => -7,
|
|
20
22
|
"pacific" => -8,
|
|
21
23
|
"alaska" => -9,
|
|
22
24
|
"aleutian" => -10,
|
|
23
|
-
"hawaiian" => -11}
|
|
25
|
+
"hawaiian" => -11} if Time.new.zone == "EST"
|
|
26
|
+
|
|
27
|
+
zones = {"eastern" => -4,
|
|
28
|
+
"central" => -5,
|
|
29
|
+
"mountain" => -6,
|
|
30
|
+
"arizona" => -6,
|
|
31
|
+
"pacific" => -7,
|
|
32
|
+
"alaska" => -8,
|
|
33
|
+
"aleutian" => -9,
|
|
34
|
+
"hawaiian" => -10} if Time.new.zone == "EDT"
|
|
24
35
|
begin
|
|
25
36
|
end_zone_offset = zones[options[:new_timezone]]
|
|
26
37
|
# to_UTC is called because the times in db are already eastern
|
|
@@ -29,6 +40,5 @@ module HackappGem
|
|
|
29
40
|
puts "Unrecognizeable timezone: #{e}"
|
|
30
41
|
end
|
|
31
42
|
end
|
|
32
|
-
|
|
33
43
|
end
|
|
34
44
|
end
|
data/lib/hackapp_gem/version.rb
CHANGED
|
@@ -3,15 +3,15 @@ require 'spec_helper'
|
|
|
3
3
|
describe HackappGem do
|
|
4
4
|
|
|
5
5
|
it "converts times to correct UTC using to_UTC" do
|
|
6
|
-
Time.zone = "EST"
|
|
7
6
|
eastern_time = Time.new()
|
|
8
|
-
expect(eastern_time.
|
|
7
|
+
expect(eastern_time.to_UTC.strftime("%B %d, %Y @ %I:%M%p")).to eql(eastern_time.utc.strftime("%B %d, %Y @ %I:%M%p"))
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
it "converts times to specified time zones" do
|
|
12
11
|
Time.zone = "EST"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
utc_time = Time.new(2002, 10, 31, 2, 2, 2, "+00:00")
|
|
13
|
+
eastern_time = Time.new(2002, 10, 31, 2, 2, 2, "-05:00")
|
|
14
|
+
expect(utc_time.change_timezone({new_timezone: "eastern"}).strftime("%B %d, %Y @ %I:%M%p")).to eql(eastern_time.strftime("%B %d, %Y @ %I:%M%p"))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
end
|