summaryrefslogtreecommitdiff
path: root/lib/optparse/time.rb
blob: 5e54b709e01ed9128f26e0e5c59c4c3e9d21f384 (plain)
1
2
3
4
5
6
7
8
9
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