Skip to content

Instantly share code, notes, and snippets.

@KameronKales
Created January 20, 2017 20:24
Show Gist options
  • Save KameronKales/7cff6295cf9506d7f9edcdc001dfe447 to your computer and use it in GitHub Desktop.
Save KameronKales/7cff6295cf9506d7f9edcdc001dfe447 to your computer and use it in GitHub Desktop.
last portion of time formatting needed
from datetime import datetime as dt
hour = dt.now().hour
for i in str(hour):
if hour < 12 and time != '00':
current_hour = hour
end_hour = current_hour + 1
period = "AM"
elif hour < 12 and time == '00':
current_hour = (hour + 1)
end_hour = (current_hour + 1)
period = "AM"
elif hour == 12:
current_hour = (hour + 1) - 12
end_hour = (current_hour + 1)
period = "PM"
elif hour > 12 and time == '00':
current_hour = (hour + 1) - 12
end_hour = (current_hour + 1)
period = "PM"
else:
hour > 12
current_hour = hour - 12
end_hour = (current_hour + 1)
period = "PM"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment