how to shift a datetime object by 12 hours in python
Question: Datetime objects hurt my head for some reason. I am writing to figure out how
to shift a date time object by 12 hours. I also need to know how to figure out
if two date time object's differ by say 1 minute or more.


Answer: The [`datetime`](http://docs.python.org/library/datetime.html) library has a
`timedelta` object specifically for this kind of thing:

    
    
    import datetime
    
    mydatetime = datetime.now() # or whatever value you want
    twelvelater = mydatetime + datetime.timedelta(hours=12)
    twelveearlier = mydatetime - datetime.timedelta(hours=12)
    
    difference = abs(some_datetime_A - some_datetime_B)
    # difference is now a timedelta object
    
    # there are a couple of ways to do this comparision:
    if difference > timedelta(minutes=1):
        print "Timestamps were more than a minute apart"
    
    # or: 
    if difference.total_seconds() > 60:
        print "Timestamps were more than a minute apart"
    

