Consider the following list of day-of-week-hour pairs in 24H
format:
{
'Mon': [9,23],
'Thu': [12, 13, 14],
'Tue': [11, 12, 14],
'Wed': [11, 12, 13, 14]
'Fri': [13],
'Sat': [],
'Sun': [],
}
and two time points, e.g.:
Start:
datetime.datetime(2015, 7, 22, 17, 58, 54, 746784)
End:
datetime.datetime(2015, 8, 30, 10, 22, 36, 363912)
Say we need to know how many hours there are between these two datetimes (either rounding up or down) for each of the day-of-week-hour pairs specified above.
How can I approach this problem in Python? I explored timedelta
and relativedelta
in a general level of detail but I didn't find anything that provides something close to this.
For simplicity, we can assume that everything refers to the same timezone.
Perhaps a simpler problem is to focus on a single day-hour pair, e.g. How many Wednesdays: 14
are there between two arbitrary datetimes?