Class: Date

Inherits:
Object show all
Defined in:
lib/user_input.rb

Class Method Summary collapse

Class Method Details

.from_user_input(value) ⇒ Object

Check for a string of the regex /[0-9]1,2/[0-9]1,2/[0-9]4/ and make a Date object out of it



58
59
60
61
62
63
64
65
66
67
# File 'lib/user_input.rb', line 58

def Date.from_user_input(value)
	if (value.kind_of?(Date))
		return value
	end
	begin
		return Date.parse(value.to_s)
	rescue ArgumentError
		return nil
	end
end