Created
November 10, 2015 13:13
-
-
Save anonymous/40b154ff36e6bb8f30ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#encoding: utf-8 | |
newT = Time.new | |
birth1 = gets.chomp | |
birth2 = gets.chomp | |
while birth2 > 12 | |
puts ' immetti un mese che esista!!' | |
birth2 = gets.chomp | |
end | |
birth3 = gets.chomp | |
while birth3 > 31 | |
puts 'non esiste un mese così lungo' | |
birth3 = gets.chomp | |
end | |
def bisesitle birth1 | |
if birth1%4 == 0 or birth1%400 == 0 | |
return true | |
else | |
return false | |
end | |
end | |
def birthday birth2 | |
conta30 = [11,02,04,06,9] | |
conta31 = [01,01,05,07,8,10,12] | |
if birth3.to_i == 30 or birth3.to_i == 31 | |
compar= conta30.include?(birth2) | |
compar2= conta31.include?(birth2) | |
if compar == true and birth3.to_i > 30 | |
puts 'non esiste un mese del genere' | |
birth2 = gets.chomp | |
birthday birth2.to_i | |
end | |
if compar2 == true and birth3.to_i > 31 | |
puts ' on esiste un mese del genere' | |
birth2 = gets.chomp | |
birthday birth2.to_i | |
end | |
end | |
end | |
def bisrec bisesitle | |
if bisesitle == true and birth2 == conta30[1] | |
if birth3 >= 30 | |
puts ' non esiste un bisestile di 30' | |
birth3 = gets.chomp | |
end | |
end | |
while bisesitle == false and birth2 == conta30[1] | |
if birth3 >= 29 | |
puts ' febbraio ha solo 28 giorni' | |
birth3 = gets.chomp | |
end | |
end | |
end | |
bisest= (conta30[1].to_i - 1) | |
end | |
dtbirth = Time.mktime(birth1.to_i,birth2.to_i,birth3.to_i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment