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



366
367
368
# File 'lib/hammer_cli/options/normalizers.rb', line 366

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

.completion_typeObject



362
363
364
# File 'lib/hammer_cli/options/normalizers.rb', line 362

def completion_type
  :datetime
end

Instance Method Details

#format(date) ⇒ Object



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

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