interpret_date 1.0.1 → 1.1.0

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: 52a8e2771eb7e9128add058b88fbef0401b3ead7
4
- data.tar.gz: 32c5852add7a8347c61a746971c66a2b385f976b
3
+ metadata.gz: 761b3663c400c791352e4930bb3d4cce8cbdc4b4
4
+ data.tar.gz: 8d78cc3192b7b4dcd601e1a857affbd04f501c76
5
5
  SHA512:
6
- metadata.gz: 661f984df6834a7afe4445045eb0e801ed7b0409faebd18ca983f8590e017b9703b09b4859d25c3fe3b6999757d82f38b0672d3571e74e18c78a7220e1e4e8c3
7
- data.tar.gz: ae9609479fb237229c6cf9eeff9203b8e78b503f43a2490f084c19d7f2584a6a2e0d2b073cb6afbec26c740babfc36a7e6a4d8f0b919926588b12ac189a8d0db
6
+ metadata.gz: 00ac81258a7c023b1ed9fd9de0f0ff9f96ccfd0f2a66d6f4eca0755b2187f35f5d11d8b543f7004194219a5f4930736021fae7c726b6194283e4455b0b42c28a
7
+ data.tar.gz: 793feddbc43b71c1c68510eea79d277b94662740a65261563cc4b829c5e4666ceee48b1a0cdbeec1354dfb9643c1a275fbb075cdeacfb5245cc726c12ca71d41
@@ -35,6 +35,8 @@ module InterpretDate
35
35
  month = date_input[0,2].to_i
36
36
  day = date_input[2,2].to_i
37
37
  year = date_input[4,2].to_i
38
+ elsif db_formatted_date(date_input)
39
+ year, month, day = date_input.split("-").collect { |element| element.to_i }
38
40
  elsif slash_based_date(date_input)
39
41
  # Break the string apart using the delimiters '-', '/', and '.', making each element an integer
40
42
  month, day, year = date_input.split(/[-\.\/]+/).collect { |element| element.to_i }
@@ -76,4 +78,9 @@ module InterpretDate
76
78
  def slash_based_date(value)
77
79
  /^\d{1,2}([-\.\/]+)\d{1,2}\1\d{2,4}$/ =~ value
78
80
  end
81
+
82
+ # Example: 2017-01-01
83
+ def db_formatted_date(value)
84
+ /^\d{4}-\d{2}-\d{2}$/ =~ value
85
+ end
79
86
  end
@@ -1,3 +1,3 @@
1
1
  module InterpretDate
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -53,6 +53,12 @@ RSpec.describe InterpretDate do
53
53
  it "returns nil if the input passed in cannot be parsed into a date" do
54
54
  expect(interpret_date("Kevin Bacon")).to eq(nil)
55
55
  end
56
+
57
+ context "when the date is a db formatted string" do
58
+ it "interprets the string as a date" do
59
+ expect(interpret_date("2017-01-01")).to eql(Date.new(2017, 01, 01))
60
+ end
61
+ end
56
62
  end
57
63
 
58
64
  describe "#interpret_dob_date" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interpret_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Squaremouth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.5.1
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Mixin for easily parsing American formatted date strings into Date objects.