Duh… while driving home today, I realized “why do I need to figure out tomorrow?” (To obtain “midnight”.) Midnight is always the same number of minutes from the start of the day. I.e. 24 hrs * 60 min/hour = 1,440 minutes in a day.
So, let’s get the minute that we’re at “now”… and then just subtract that from 1440 to get the minutes that are left in the day. Thus take 2:
from datetime import datetime now = datetime.now() minutes_left = 24 * 60 - (now.hour * 60 + now.minute) print "As of " + str(now) + \ ", there are %d minutes until midnight" % minutes_left
Learnings & TODOs
Realized I do need to go back and learn more of the basics, to get a grasp on correct teminology. Found this post which gave some nice pointers on things to review in the replies:
I give advise you to read thoroughly the parts
3.1. Objects , values and types http://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy
and
4.1. Naming and binding http://docs.python.org/reference/executionmodel.html#naming-and-binding
References:
- http://docs.python.org/2/library/datetime.html
- http://stackoverflow.com/questions/5103329/how-to-find-out-what-methods-properties-etc-a-python-module-possesses