Created
July 13, 2013 05:08
-
-
Save Verurteilt/5989487 to your computer and use it in GitHub Desktop.
Topic 3 Q 9 Pyschools
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
def time24hr(tstr): | |
x=tstr[-2:] | |
y=tstr.split(':') | |
z=y[0] | |
global v | |
v=y[1] | |
global b | |
global c | |
global total | |
if x== "am": | |
b=v.split("a") | |
c=b[0] | |
else: | |
b=v.split("p") | |
c1=b[0] | |
if x == "am" and z != "12": | |
total="%s%shr"%(z,c) | |
elif x == "am" and z == "12": | |
z="00" | |
total="%s%shr"%(z,c) | |
elif x == "pm" and z != "12": | |
z=int(z) | |
z=z+12 | |
total="%s%shr"%(z,c1) | |
elif x == "pm" and z == "12": | |
total="%s%shr"%(z,c1) | |
return total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment