mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Closes #27661: Added tzinfo keyword argument to datetime.combine.
This commit is contained in:
parent
711120d8fd
commit
43746c3770
5 changed files with 50 additions and 24 deletions
|
@ -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()."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue