parse_date 0.3.4 → 0.4.0

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
  SHA256:
3
- metadata.gz: c818fd11526f5dbddb22a29801089a6ff9946d0eb23a208af5316a34c2201836
4
- data.tar.gz: bb5b1f93425fe42659b144554b8a21dc95615a7b7e35ac1a361d7696869367f1
3
+ metadata.gz: 367f2e3cc7710655783c53692b76d6c483be5dd197047b0a285857c2e8b29b10
4
+ data.tar.gz: 37da36fa61807abcc852bb1dc4c5f4f05313dc87e25ad6d03db7a3f64da34998
5
5
  SHA512:
6
- metadata.gz: 5b8f75b733e86e4f6f6178279a7959a6693443ddd2bb0c1315957b3d197993c2bd19790516f5170b6458f0ae4209ce3bf8b9e83fdb9b30b373e0bf2896aed93d
7
- data.tar.gz: a3adec7a2979f591386a9674f7d096f70dc9146af27ed3b734404f195fa35c820b5218a850365ac386a6d478cc71bf7b7f1d78ffcdf523d6d4547b3d52caeff3
6
+ metadata.gz: 31a6ec4a2b621f6689ecc4151f7809e3fc861a491382117350f2b9404db6f6c753206dc263d028b04a54aaa23b14c8cfcf036d3de7139d1f61dd3a3fdfb07d6e
7
+ data.tar.gz: 289196806a4c8acba6904525adb65e5afe429dd5ee74acfb9ae75ea30980bc52f0ef1112871f948e0cd0454a9e0b303ac407b030d4562f8eac898cf3f8f5a6fe
data/README.md CHANGED
@@ -67,9 +67,11 @@ ParseDate.parse_range('996–1021 CE') # (996..1021).to_a (di
67
67
  ParseDate.parse_range('1975 - 1905') # last year > first year, raises error
68
68
  ParseDate.parse_range('-100 - -150') # last year > first year, raises error
69
69
  ParseDate.parse_range('1975 or 1905') # last year > first year, raises error
70
- ParseDate.parse_range('2050') # year later than current year + 1, raises error
71
- ParseDate.parse_range('random text') # can't parse years, raises error
72
- ParseDate.parse_range(nil) # can't parse years, raises error
70
+ ParseDate.parse_range('1975 - 2050') # single invalid year endpoint, raises error
71
+ ParseDate.parse_range('2050') # nil - only invalid year endpoints present
72
+ ParseDate.parse_range('2045 - 2050') # nil - only invalid year endpoints present
73
+ ParseDate.parse_range('random text') # nil - can't parse years
74
+ ParseDate.parse_range(nil) # nil - can't parse years
73
75
 
74
76
  ParseDate.earliest_year('12/25/00') # 2000
75
77
  ParseDate.earliest_year('5-1-21') # 1921
@@ -42,6 +42,7 @@ class ParseDate
42
42
  def self.parse_range(date_str)
43
43
  first = earliest_year(date_str)
44
44
  last = latest_year(date_str)
45
+ return nil unless first || last
45
46
  raise ParseDate::Error, "Unable to parse range from '#{date_str}'" unless year_range_valid?(first, last)
46
47
 
47
48
  range_array(first, last)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ParseDate
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk