summaryrefslogtreecommitdiff
path: root/jni/ruby/lib/optparse/date.rb
blob: d680559f3708a1374657a3f9bdeda5a24b009038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'optparse'
require 'date'

OptionParser.accept(DateTime) do |s,|
  begin
    DateTime.parse(s) if s
  rescue ArgumentError
    raise OptionParser::InvalidArgument, s
  end
end
OptionParser.accept(Date) do |s,|
  begin
    Date.parse(s) if s
  rescue ArgumentError
    raise OptionParser::InvalidArgument, s
  end
end