Created
January 3, 2009 10:22
-
-
Save ravicious/42822 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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