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



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

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

.completion_typeObject



357
358
359
# File 'lib/hammer_cli/options/normalizers.rb', line 357

def completion_type
  :datetime
end

Instance Method Details

#format(date) ⇒ Object



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

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