Closes #27661: Added tzinfo keyword argument to datetime.combine.

This commit is contained in:
Alexander Belopolsky 2016-08-02 17:49:30 -04:00
parent 711120d8fd
commit 43746c3770
5 changed files with 50 additions and 24 deletions

View file

@ -1479,15 +1479,17 @@ class datetime(date):
return cls.utcfromtimestamp(t)
@classmethod
def combine(cls, date, time):
def combine(cls, date, time, tzinfo=True):
"Construct a datetime from a given date and a given time."
if not isinstance(date, _date_class):
raise TypeError("date argument must be a date instance")
if not isinstance(time, _time_class):
raise TypeError("time argument must be a time instance")
if tzinfo is True:
tzinfo = time.tzinfo
return cls(date.year, date.month, date.day,
time.hour, time.minute, time.second, time.microsecond,
time.tzinfo, fold=time.fold)
tzinfo, fold=time.fold)
def timetuple(self):
"Return local time tuple compatible with time.localtime()."