Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created January 3, 2009 10:22
Show Gist options
  • Save ravicious/42822 to your computer and use it in GitHub Desktop.
Save ravicious/42822 to your computer and use it in GitHub Desktop.
require 'date'
def Scan(text)
case text
when /^([0-9]{1,2})[-\.]([0-9]{1,2})[-\.]([0-9]{4})/
puts "Poprawna data"
else
puts "Niepoprawna data, sprobuj jeszcze raz"
end
end
loop do
puts "Podaj pierwsza date (format: dd-mm-rrrr)"
d1 = gets.chop!
while Scan(d1) == nil
d1 = gets.chop!
end
puts "Podaj druga date (format: dd-mm-rrrr)"
d2 = gets.chop!
while Scan(d2) == nil
d2 = gets.chop!
end
puts "OK, obie daty sa poprawne"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment