date_utc_parser 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module DateUtcParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -27,7 +27,7 @@ module DateUtcParser
27
27
  end
28
28
 
29
29
  def self.parse_from_time(date)
30
- date.utc? ? date : date.utc
30
+ date.utc
31
31
  end
32
32
  end
33
33
 
@@ -1,5 +1,9 @@
1
+ require 'ruby-debug'
1
2
  require_relative '../../lib/date_utc_parser'
2
3
  require 'time'
4
+ require 'active_support/core_ext/numeric/time'
5
+ require 'active_support/core_ext/time/zones'
6
+ require 'active_support/core_ext/date/calculations'
3
7
 
4
8
  describe DateUtcParser, "Parsing:" do
5
9
  subject { described_class.parse(date) }
@@ -50,16 +54,28 @@ describe DateUtcParser, "Parsing:" do
50
54
  context 'and is a utc date' do
51
55
  let(:date) { Time.now.utc }
52
56
 
53
- it "returns the time object" do
57
+ it "returns the utc time object" do
54
58
  subject.should == date
55
59
  end
56
60
  end
57
61
 
62
+ context 'and is a utc time with zone object' do
63
+ let(:date) { 2.weeks.ago }
64
+
65
+ before do
66
+ Time.zone = 'UTC'
67
+ end
68
+
69
+ it 'converts it to a standard utc time object' do
70
+ subject.should_not be_a(ActiveSupport::TimeWithZone)
71
+ subject.should be_utc
72
+ end
73
+ end
74
+
58
75
  context 'but is not a utc date' do
59
76
  let(:date) { Time.now }
60
77
 
61
78
  it "returns the time object as utc" do
62
- subject.utc?.should be_true
63
79
  subject.should == date.utc
64
80
  end
65
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_utc_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-18 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -68,3 +68,4 @@ signing_key:
68
68
  specification_version: 3
69
69
  summary: Make working with UTC Time more fun
70
70
  test_files: []
71
+ has_rdoc: