timelord 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5155bc20aeb42f6a425662afb50e602404bf288
4
- data.tar.gz: 620672c681562bddd15f34ae4d1dce1f33124595
3
+ metadata.gz: 60169c613d4bfbc330e87f3bd81f39bd07c1a7cc
4
+ data.tar.gz: 184555c3231a91a8a3057dacfb1fa527fc176967
5
5
  SHA512:
6
- metadata.gz: a05dcad148204053e8d4ce6e0ccae8d89d3be17c1a1d27215cf8f7d18d073acee203da254978afc94fc58697fa837e5df5cb077168512b483da6b78e6e51a216
7
- data.tar.gz: 06a94a35fef19b24734eb99d20903a9517bbeab86eb7655261725324a6c6b3954a25773df3adc489c582b400dce60f20a19c11bd0d658c43ab5e9f7dcecf8fb3
6
+ metadata.gz: baf409a8ef5a0dcd8a42683bf2e52f9c9b8d811f29cf7eb326cc30d04a2ce4b06cfe3231e5ff87a0589ed4ded915c79384b3f410a851364a5d0f2268a0996aa5
7
+ data.tar.gz: 732b6c734a74ee0a40cf638f92ea4fceecbef9c9a7471012153b4b2dcbae48cab1be6302648d1f387429a101b287136d287a710c5808333693a55b7d4d3f7663
data/README.md CHANGED
@@ -24,7 +24,7 @@ To use the american date format pass in :american as the second parameter
24
24
 
25
25
  ```ruby
26
26
  Timelord.parse("11/01").to_s # "2011-01-11"
27
- Timelord.parse("11/01", :american) # "2011-11-01"
27
+ Timelord.parse("11/01", format: :american) # "2011-11-01"
28
28
  ```
29
29
 
30
30
  ## In the future
@@ -8,7 +8,7 @@ require 'timelord/current_weekday'
8
8
  require 'timelord/matcher_loader'
9
9
 
10
10
  module Timelord
11
- VERSION = "0.0.10"
11
+ VERSION = "0.0.11"
12
12
 
13
13
  # Parses a date str. Second parameter switches between international and american date formats.
14
14
  #
@@ -1,12 +1,23 @@
1
1
  module Timelord
2
2
  class YearLastMatcher < Matcher
3
3
  REGEX = /\b(\d{1,2})\/(\d{1,2})\/(\d{2}(\d{2})?)\b/i
4
+ CURRENT_PREFIX = 2000
4
5
 
5
6
  def to_date
6
7
  if format == :american
7
- Date.civil(match[3].to_i, match[1].to_i, match[2].to_i)
8
+ Date.civil(to_year(match[3]), match[1].to_i, match[2].to_i)
8
9
  else
9
- Date.civil(match[3].to_i, match[2].to_i, match[1].to_i)
10
+ Date.civil(to_year(match[3]), match[2].to_i, match[1].to_i)
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def to_year(year_number)
17
+ if year_number.length == 2
18
+ CURRENT_PREFIX + year_number.to_i
19
+ else
20
+ year_number.to_i
10
21
  end
11
22
  end
12
23
  end
@@ -128,6 +128,11 @@ describe Timelord, 'parse' do
128
128
  Timelord.parse("March 1 I need to do stuff.").should == first_of_march
129
129
  end
130
130
 
131
+ it 'parses mm/dd/yy correctly' do
132
+ oct_12 = Date.civil(2015, 10, 12)
133
+ Timelord.parse("Stuff 10/12/15", format: :american).should == oct_12
134
+ end
135
+
131
136
  after do
132
137
  Timecop.return
133
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timelord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timecop
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.2.2
113
+ rubygems_version: 2.5.1
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Pull dates out of strings