Sha256: cdf7ac61b17cc846748896e66152bb5d088c38461de58a9bed9225879e7976e4

Contents?: true

Size: 368 Bytes

Versions: 6

Compression:

Stored size: 368 Bytes

Contents

# frozen_string_literal: false
require_relative '../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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
optparse-0.6.0 lib/optparse/date.rb
optparse-0.5.0 lib/optparse/date.rb
cmd-optparse.rb-0.1.0 lib/optparse/date.rb
optparse-0.4.0 lib/optparse/date.rb
optparse-0.3.1 lib/optparse/date.rb
optparse-0.3.0 lib/optparse/date.rb