fuzzy-date 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/fuzzy-date.rb +15 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b9096445fca7db3278f700ad1df4d49963526b
|
4
|
+
data.tar.gz: ac5141a7cfe0c17aa0398f0e88c0e5bee2ef67cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af1096e90f53de76e59308f280be35e39b4d927ab866107aa1822f6d8577d482200166e6432cb131240360e7afafe94c794bd98ec99b938d942a80b87e49cc0e
|
7
|
+
data.tar.gz: d8fe6b9bf8c51530e25951c12e243da9ca0f6302a7fd375d5a7ab8bf96b554771a145c09e1aeec4e73ce6b02e5611d97ac85ebcdd1672165593861c75ab67643
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2014 Digital Charleston, LLC
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/fuzzy-date.rb
CHANGED
@@ -2,6 +2,8 @@ require 'date'
|
|
2
2
|
|
3
3
|
class FuzzyDate
|
4
4
|
|
5
|
+
DATE_SEPARATOR = '[^A-Za-z0-9]'
|
6
|
+
|
5
7
|
@month_names = {
|
6
8
|
1 => 'January',
|
7
9
|
2 => 'February',
|
@@ -101,17 +103,11 @@ class FuzzyDate
|
|
101
103
|
|
102
104
|
return '' if date == ''
|
103
105
|
|
104
|
-
date_parts =
|
105
|
-
date_parts[ :original ] = date
|
106
|
-
date_parts[ :circa ] = false
|
107
|
-
date_parts[ :year ] = nil
|
108
|
-
date_parts[ :month ] = nil
|
109
|
-
date_parts[ :day ] = nil
|
110
|
-
date_parts[ :era ] = 'AD'
|
106
|
+
date_parts = set_up_date_parts date
|
111
107
|
|
112
108
|
date_in_parts = []
|
113
109
|
|
114
|
-
date_separator = Regexp.new
|
110
|
+
date_separator = Regexp.new DATE_SEPARATOR, true
|
115
111
|
|
116
112
|
#- Split the string
|
117
113
|
|
@@ -238,4 +234,15 @@ class FuzzyDate
|
|
238
234
|
def self.clean_parameter( date )
|
239
235
|
date.to_s.strip if date.respond_to? :to_s
|
240
236
|
end
|
237
|
+
|
238
|
+
def self.set_up_date_parts( date )
|
239
|
+
date_parts = {}
|
240
|
+
date_parts[ :original ] = date
|
241
|
+
date_parts[ :circa ] = false
|
242
|
+
date_parts[ :year ] = nil
|
243
|
+
date_parts[ :month ] = nil
|
244
|
+
date_parts[ :day ] = nil
|
245
|
+
date_parts[ :era ] = 'AD'
|
246
|
+
date_parts
|
247
|
+
end
|
241
248
|
end
|