I already have working code for this but i'm still very new to python and I know there is a better way of doing this. This is the code i've used in a motion detection script on my raspberry pi. It simply checks if it occurs in the timeframe when i'm not home. I've pulled the code from the rest of the script:
import time
import datetime
import calendar
now = datetime.datetime.now()
x = time.localtime(time.time())
starttime = datetime.datetime(x.tm_year,x.tm_mon,x.tm_mday,8,20,0)
start_timestamp = calendar.timegm(starttime.timetuple())
now_timestamp = calendar.timegm(now.timetuple())
future = starttime + datetime.timedelta(minutes=550)
future_timestamp = calendar.timegm(future.timetuple())
print start_timestamp
print now_timestamp
print future_timestamp
if now_timestamp > start_timestamp and now_timestamp < future_timestamp:
print "bam!"
All i need to do is see if the current time is between the start time and the end time. I'm sure there is a way of writing this much more efficiently, I think my code is fairly obtuse.