Permalink
Browse files

Merge pull request #18 from adamcrown/datetimes_with_punctuation

Support punctuation in dates.
  • Loading branch information...
peterc committed Aug 15, 2012
2 parents 434db9d + 30d64a3 commit e4a028e6027c75160db495bbf913b4e6116d0fcc
Showing with 620 additions and 3 deletions.
  1. +4 −2 lib/pismo/internal_attributes.rb
  2. +4 −1 test/corpus/metadata_expected.yaml
  3. +612 −0 test/corpus/thegoodbookblog.html
@@ -76,7 +76,7 @@ def html_title
def datetime
# TODO: Clean all this mess up
- mo = %r{(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|January|February|March|April|May|June|July|August|September|October|November|December)}i
+ mo = %r{(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|January|February|March|April|May|June|July|August|September|October|November|December)\.?}i
regexen = [
/#{mo}\b\s+\d+\D{1,10}\d{4}/i,
@@ -86,6 +86,7 @@ def datetime
/\d+(th|st|rd).{1,10}#{mo}\b[^\d]{1,10}\d+/i,
/\d+\s+#{mo}\b[^\d]{1,10}\d+/i,
/on\s+#{mo}\s+\d+/i,
+ /#{mo}\s+\d+,? \d{4}+/i,
/#{mo}\s+\d+/i,
/\d{4}[\.\/\-]\d{2}[\.\/\-]\d{2}/,
/\d{2}[\.\/\-]\d{2}[\.\/\-]\d{4}/
@@ -102,7 +103,8 @@ def datetime
# Clean up the string for use by Chronic
datetime.strip!
datetime.gsub!(/(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)[^\w]*/i, '')
- datetime.gsub!(/(mon|tues|tue|weds|wed|thurs|thur|thu|fri|sat|sun)[^\w]*/i, '')
+ datetime.gsub!(/(mon|tues|tue|weds|wed|thurs|thur|thu|fri|sat|sun)\.?[^\w]*/i, '')
+ datetime.gsub!(/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\./i, '\1')
datetime.sub!(/on\s+/, '')
datetime.gsub!(/\,/, '')
datetime.sub!(/(\d+)(th|st|rd)/, '\1')
@@ -69,4 +69,7 @@
:title: 18 Incredible CSS3 Effects You Have Never Seen Before
:lede: "CSS3 is hot these days and will soon be available in most modern browser. Just recently, I started to become aware to the present of CSS3 around the web. I can see some of the websites such as twitter and designer portfolios websites are using it. Also, I have started to implement it to my own project as well and I really love it!"
:sentences: CSS3 is hot these days and will soon be available in most modern browser. Just recently, I started to become aware to the present of CSS3 around the web. I can see some of the websites such as twitter and designer portfolios websites are using it.
- :datetime: 2010-06-02 12:00:00 +01:00
+ :datetime: 2010-06-02 12:00:00 +01:00
+:thegoodbookblog:
+ :title: Signs Of Life
+ :datetime: 2012-07-25 12:00:00 +01:00
Oops, something went wrong.

0 comments on commit e4a028e

Please sign in to comment.