date_utc_parser 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,9 @@ module DateUtcParser
6
6
  date.is_a?(Time) ? parse_from_time(date) : parse_from_string(date)
7
7
  end
8
8
 
9
- def self.parse_from_string(date)
10
- Time.parse(date) if date && date =~ iso8601_pattern
9
+ def self.parse_from_string(time)
10
+ parsed_time = Time.parse(time) if time
11
+ parsed_time if parsed_time && (time =~ iso8601_pattern || parsed_time.utc?)
11
12
  rescue ArgumentError
12
13
  # date could not be parsed
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module DateUtcParser
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -38,9 +38,11 @@ describe DateUtcParser, "Parsing:" do
38
38
 
39
39
  context "when the date is a valid date time format, and is a valid date, and is utc" do
40
40
  let(:date) { "2012-05-12T20:46:51Z" }
41
+ let(:date2) { "2012-07-04 00:35:36 UTC" }
41
42
 
42
43
  it 'returns the parsed date' do
43
- subject.should == Time.parse(date)
44
+ described_class.parse(date).should == Time.parse(date)
45
+ described_class.parse(date2).should == Time.parse(date2)
44
46
  end
45
47
  end
46
48
 
metadata CHANGED
@@ -1,47 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: date_utc_parser
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Matt Simpson
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-07-07 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 10
31
- - 0
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
32
21
  version: 2.10.0
33
22
  type: :development
34
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.10.0
35
30
  description: Takes an object and returns the equivalent UTC Time object
36
- email:
31
+ email:
37
32
  - matt.simpson3@gmail.com
38
33
  executables: []
39
-
40
34
  extensions: []
41
-
42
35
  extra_rdoc_files: []
43
-
44
- files:
36
+ files:
45
37
  - .gitignore
46
38
  - .rspec
47
39
  - Gemfile
@@ -51,39 +43,28 @@ files:
51
43
  - lib/date_utc_parser.rb
52
44
  - lib/date_utc_parser/version.rb
53
45
  - spec/lib/date_utc_parser_spec.rb
54
- has_rdoc: true
55
46
  homepage: http://github.com/ionicmobile/date_utc_parser
56
47
  licenses: []
57
-
58
48
  post_install_message:
59
49
  rdoc_options: []
60
-
61
- require_paths:
50
+ require_paths:
62
51
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
52
+ required_ruby_version: !ruby/object:Gem::Requirement
64
53
  none: false
65
- requirements:
54
+ requirements:
66
55
  - - ~>
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 1
70
- - 9
71
- - 2
56
+ - !ruby/object:Gem::Version
72
57
  version: 1.9.2
73
- required_rubygems_version: !ruby/object:Gem::Requirement
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
59
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
- version: "0"
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
81
64
  requirements: []
82
-
83
65
  rubyforge_project:
84
- rubygems_version: 1.3.7
66
+ rubygems_version: 1.8.24
85
67
  signing_key:
86
68
  specification_version: 3
87
69
  summary: Make working with UTC Time more fun
88
70
  test_files: []
89
-