class OptimistXL::ChronicDateOption
Option
for dates using Chronic gem. Mainly for compatibility with Optimist. Use of Chronic switches to United States formatted dates (MM/DD/YYYY) as opposed to DD/MM/YYYY
Public Instance Methods
parse(paramlist, _neg_given)
click to toggle source
# File lib/optimist_xl/chronic.rb, line 15 def parse(paramlist, _neg_given) paramlist.map do |pg| pg.map do |param| parse_date_param(param) end end end
type_format()
click to toggle source
# File lib/optimist_xl/chronic.rb, line 14 def type_format ; "=<date>" ; end
Private Instance Methods
parse_date_param(param)
click to toggle source
# File lib/optimist_xl/chronic.rb, line 24 def parse_date_param(param) if param.respond_to?(:year) and param.respond_to?(:month) and param.respond_to(:day) return Date.new(param.year, param.month, param.day) end time = Chronic.parse(param) time ? Date.new(time.year, time.month, time.day) : Date.parse(param) rescue ArgumentError raise CommandlineError, "option '#{self.name}' needs a valid date" end