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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41c3b313756676b4996c1983f08448de8efcb0e8
4
- data.tar.gz: c8532c6dda3ab8555519667afaa837ad6a732722
3
+ metadata.gz: d6beb3ae222f109fb32e7c82a46e0e97145e88c5
4
+ data.tar.gz: d8b015c6ecaa0cd47d4c8d78bea5aa786bd8d0b6
5
5
  SHA512:
6
- metadata.gz: 29fb442b5d8733f8b72463efa06a6cebbf1387ed2143a52fa671c73976e166ce01c2105562e2c6a2a3b978111f64bc40623cdf824c5c12730c654f8618c25958
7
- data.tar.gz: a6e5d3a6a33e873a21986d98587ad1e6e1e929ca918ff1a53489a2b54c426bd06456654f7bd4c9c5c774960f029473a88a229057b1ff60e7138f5450384451b7
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
- self.utc
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" => -4,
17
- "central" => -5,
18
- "mountain" => -6,
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
@@ -1,3 +1,3 @@
1
1
  module HackappGem
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -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.utc.strftime("%B %d, %Y @ %I:%M%p")).to eql(eastern_time.to_UTC.strftime("%B %d, %Y @ %I:%M%p"))
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
- eastern_time = Time.new()
14
- expect(eastern_time.strftime("%B %d, %Y @ %I:%M%p")).to eql(eastern_time.utc.change_timezone({new_timezone: "eastern"}).strftime("%B %d, %Y @ %I:%M%p"))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackapp_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Corletti