Class: HammerCLI::Options::Normalizers::DateTime

Inherits:
AbstractNormalizer show all
Defined in:
lib/hammer_cli/options/normalizers.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNormalizer

#complete, #completion_type, #description, inherited

Class Method Details

.common_descriptionObject



364
365
366
# File 'lib/hammer_cli/options/normalizers.rb', line 364

def common_description
  _('Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format')
end

.completion_typeObject



360
361
362
# File 'lib/hammer_cli/options/normalizers.rb', line 360

def completion_type
  :datetime
end

Instance Method Details

#format(date) ⇒ Object



369
370
371
372
373
374
# File 'lib/hammer_cli/options/normalizers.rb', line 369

def format(date)
  raise ArgumentError unless date
  ::DateTime.parse(date).to_s
rescue ArgumentError
  raise ArgumentError, _("'%s' is not a valid date.") % date
end