Pythonic way to combine datetime.date and datetime.time objects

DatetimePython

Datetime Problem Overview


I have two objects that represent the same event instance --- one holds the date, the other the time of this event, and I want to create a datetime object.

Since one can't simply add date and time objects (following call fails):

 datetime.date(2011, 01, 01) + datetime.time(10, 23)

Datetime Solutions


Solution 1 - Datetime

It's in the python docs.

import datetime
datetime.datetime.combine(datetime.date(2011, 1, 1), 
                          datetime.time(10, 23))

returns

datetime.datetime(2011, 1, 1, 10, 23)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjb.View Question on Stackoverflow
Solution 1 - DatetimeeumiroView Answer on Stackoverflow