Skip to content

Instantly share code, notes, and snippets.

@dalinaum
Last active May 23, 2018 13:03
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 dalinaum/3ac1065bb3e3f178d442573fd31f0169 to your computer and use it in GitHub Desktop.
Save dalinaum/3ac1065bb3e3f178d442573fd31f0169 to your computer and use it in GitHub Desktop.
#!/bin/python3
import os
import sys
from datetime import datetime
def tc1(s):
if not s.endswith("PM"):
return s[:8]
else:
return str(int(s[0:2]) + 12) + s[2:8]
def tc2(s):
my_date = datetime.strptime(s, '%I:%M:%S%p')
return my_date.strftime("%H:%M:%S")
s = "07:05:45PM"
print(tc1(s))
print(tc2(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment