diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-05 10:27:34 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-05 10:27:34 +0000 |
commit | 9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (patch) | |
tree | 7acd7b77321fdbc63149b47fde3bace6f7733614 /lib/parsedate.rb | |
parent | 06d4e3b42d836b762c29cdc9dc7181caf14dcdec (diff) |
990205
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/parsedate.rb')
-rw-r--r-- | lib/parsedate.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/parsedate.rb b/lib/parsedate.rb index 5ffd2da47c..e27735b755 100644 --- a/lib/parsedate.rb +++ b/lib/parsedate.rb @@ -9,7 +9,7 @@ module ParseDate 'thu' => 4, 'fri' => 5, 'sat' => 6 } DAYPAT = DAYS.keys.join('|') - def parsedate(date) + def parsedate(date, guess=false) # part of ISO 8601 # yyyy-mm-dd | yyyy-mm | yyyy # date hh:mm:ss | date Thh:mm:ss @@ -63,6 +63,19 @@ module ParseDate mon = MONTHS[$2.downcase] year = $3.to_i end + if guess + if year < 100 + if year >= 69 + year += 1900 + else + year += 2000 + end + end + elsif date.sub!(/(\d+)-(#{MONTHPAT})-(\d+)/i, ' ') + mday = $1.to_i + mon = MONTHS[$2.downcase] + year = $3.to_i + end return year, mon, mday, hour, min, sec, zone, wday end |