summaryrefslogtreecommitdiff
path: root/lib/optparse/time.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-12 16:40:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-12 16:40:06 +0000
commitd554a55d9b98dc832fe0257f8696dc93b211789d (patch)
treea46ae9b2032a5ca69ad0364f273a636627d1eaad /lib/optparse/time.rb
parent6af4aebc954f548298559e49719aec84e8653adc (diff)
import
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/optparse/time.rb')
-rw-r--r--lib/optparse/time.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/optparse/time.rb b/lib/optparse/time.rb
new file mode 100644
index 0000000..5e54b70
--- /dev/null
+++ b/lib/optparse/time.rb
@@ -0,0 +1,10 @@
+require 'optparse'
+require 'parsedate'
+
+OptionParser.accept(Time) do |s|
+ begin
+ Time::mktime(*ParseDate::parsedate(s)[0...6])
+ rescue
+ raise OptionParser::InvalidArgument, s
+ end
+end