I need to construct datetime object from different parameters. For example, I get these parameters:
- integer number from 0 to 6. This one indicates weekday.
- hour and minutes in float format (from 0.0 to 24.0).
And then I know which week of the current year it is going to be. So, for example, let say that datetime should be from 2014-07-18 00:00:00
to 2014-07-24 23:59:00
(seconds can be ignored and left at 00
). So to get exact datetime I need to use above defined parameters.
Let say I would get these parameters 4
(meaning Friday), and 9.5
(meaning 09:30
).
So by doing such construction, I should get a date that would be: 2014-07-22 09:30:00
. How could accomplish such thing?
Do I need to somehow get for example day of the month by knowing which is the week of the year and which weekday it is?
P.S. A bit more detailed example of what I'm trying to accomplish
from datetime import datetime
today = datetime.today() #using this to get the week I'll be working with.
today = today.replace(day=?) #how to get which day I
#need to enter by having weekday and knowing that week is the present one?