def get_datetime(cls, request, date_attr, time_attr):
"""Extracts a UTC datetime object from the given request
:param request: the request object
:param date_attr: the attribute name
:return: datetime.datetime
"""
date_part = datetime.datetime.strptime(
request.params[date_attr][:-4],
'%a, %d %b %Y %H:%M:%S'
)
time_part = datetime.datetime.strptime(
request.params[time_attr][:-4],
'%a, %d %b %Y %H:%M:%S'
)
# update the time values of date_part with time_part
return date_part.replace(
hour=time_part.hour,
minute=time_part.minute,
second=time_part.second,
microsecond=time_part.microsecond
)
评论列表
文章目录