Created
December 12, 2017 21:32
-
-
Save dbhalling/82820813c9687655f307b18b13e00c96 to your computer and use it in GitHub Desktop.
#Time Conversion Technical Exam 2
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
#Time Conversion Technical Exam 2 | |
#puts "Please enter the standard time including the seconds in this format XX:XX:XXAM" | |
#st = gets.chomp.to_s | |
st = "12:00:45AM" | |
#st = "01:12:15PM" | |
#st = "12:00:00AM" | |
def solution(st) | |
if st[8] == "A" | |
mt = st.delete "AM" | |
else | |
mt = st.delete "PM" | |
mta = mt.chars | |
h1 = mt[1].to_i + 2 | |
h1.to_s | |
mta = mta.drop(2) | |
mta = mta.reverse | |
mta = mta.push(h1).push("1") | |
mt = mta.reverse.join("") | |
end | |
if st == "12:00:00AM" | |
mt = "00:00:00" | |
end | |
return mt | |
end | |
puts "The 24 hour time is #{solution(st)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment