summaryrefslogtreecommitdiff
path: root/lib/parsedate.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-05 10:27:34 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-05 10:27:34 +0000
commit1ef2a1e88643421a15bbf98821a0ecf9164dc2a1 (patch)
tree7acd7b77321fdbc63149b47fde3bace6f7733614 /lib/parsedate.rb
parent62e648e148b3cb9f96dcce808c55c02b7ccb4486 (diff)
This commit was manufactured by cvs2svn to create tag
'v1_3_1_990205'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_3_1_990205@392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/parsedate.rb')
-rw-r--r--lib/parsedate.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 68550c6505..e27735b755 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -8,8 +8,8 @@ module ParseDate
'sun' => 0, 'mon' => 1, 'tue' => 2, 'wed' => 3,
'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
@@ -58,6 +58,23 @@ module ParseDate
if $3
year = $3.to_i
end
+ elsif date.sub!(/(\d+)-(#{MONTHPAT})-(\d+)/i, ' ')
+ mday = $1.to_i
+ 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