def allDayForDate(self,this_date,timeZone=None):
'''
This method determines whether the occurrence lasts the entirety of
a specified day in the specified time zone. If no time zone is specified,
then it uses the default time zone). Also, give a grace period of a few
minutes to account for issues with the way events are sometimes entered.
'''
if isinstance(this_date,datetime):
d = this_date.date()
else:
d = this_date
date_start = datetime(d.year,d.month,d.day)
naive_start = self.startTime if timezone.is_naive(self.startTime) else timezone.make_naive(self.startTime, timezone=timeZone)
naive_end = self.endTime if timezone.is_naive(self.endTime) else timezone.make_naive(self.endTime, timezone=timeZone)
return (
# Ensure that all comparisons are done in local time
naive_start <= date_start and
naive_end >= date_start + timedelta(days=1,minutes=-30)
)
评论列表
文章目录