rounding up time in python error
Question: I get the following error when trying to round up time,

    
    
    AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
    

fajr_jamaat1 printout is 1900-01-01 04:25:00 Please help?

    
    
    from datetime import datetime, timedelta
    
    def round_up(tm):
        upmins = math.ceil(float(tm.minute)/10)*10
        diffmins = upmins - tm.minute
        newtime = tm + datetime.timedelta(minutes=diffmins)
        newtime = newtime.replace(second=0)
        return newtime
    
    cnx = mysql.connector.connect(host=mysql_remote_host, user=mysql_remote_host_user, password=mysql_remote_host_password, database=mysql_remote_host_database)
    cursor = cnx.cursor()
    cursor.execute("select * from paramatta_prayertimes WHERE id =1")
    results = cursor.fetchall()
    id, date, fajr_begins, fajr_jamaat, sunrise, zuhr_begins, zuhr_jamaat, asr_begins, asr_jamaat, maghrib_jamaat, isha_begins, isha_jamaat = results[0]
    cursor.close()
    print fajr_begins
    
    fajr_jamaat1=(timedelta(minutes=20) + datetime.strptime(str(fajr_begins), "%H:%M:%S"))
    print fajr_jamaat1
    round_up(fajr_jamaat1)
    


Answer: Since you imported your functions as

    
    
    from datetime import datetime, timedelta
    

You do not need to call the function as

    
    
    datetime.timedelta
    

You simply call the function by its name

    
    
    timedelta
    

If you prefer to use the former syntax, just import the module itself

    
    
    import datetime
    

Then you can say

    
    
    datetime.datetime
    datetime.timedelta
    

