summaryrefslogtreecommitdiff
path: root/lib/optparse/time.rb
blob: 402cadcf167eabac1ff0b1182aa54c6fff598579 (plain)
1
2
3
4
5
6
7
8
9
10
require 'optparse'
require 'time'

OptionParser.accept(Time) do |s,|
  begin
    (Time.httpdate(s) rescue Time.parse(s)) if s
  rescue
    raise OptionParser::InvalidArgument, s
  end
end