Skip to content

Instantly share code, notes, and snippets.

@story645
Created July 1, 2020 15:47
Show Gist options
  • Save story645/b43217c5c0d96c7c07f69d1125330a13 to your computer and use it in GitHub Desktop.
Save story645/b43217c5c0d96c7c07f69d1125330a13 to your computer and use it in GitHub Desktop.
def to24(time):
try:
hour, minute, local = time.split(":")
except (ValueError, AttributeError):
return time
h = int(hour)
m = int(minute)
if time.endswith('AM'):
if h == 12:
h = 0
timeo = h*100 + m
elif time.endswith('PM'):
timeo = (h+12) * 100 + m
return timeo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment