Skip to content

Instantly share code, notes, and snippets.

@Verurteilt
Created July 13, 2013 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Verurteilt/5989487 to your computer and use it in GitHub Desktop.
Save Verurteilt/5989487 to your computer and use it in GitHub Desktop.
Topic 3 Q 9 Pyschools
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