summaryrefslogtreecommitdiff
path: root/lib/rubygems/vendor/optparse/lib/optparse/time.rb
blob: c59e1e4cedd19d88bf16a2654b52403f9f5b807a (plain)
1
2
3
4
5
6
7
8
9
10
11
# frozen_string_literal: false
require_relative '../optparse'
require 'time'

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