A datetime column of my dataframe is in the POSIXct format, e.g. "2014-08-08 14:22:00".
I'd like to update such datetime values if they fall out of working hours. The target value needs to be the closest 9am of a weekday in the future. This means:
- If the current value is in the early morning of a weekday, update it to 9am of the same day;
- If the current value is after 5pm prior to a weekday, update it to 9am of the next day;
- If the current value is between 5pm of a Friday and 5pm of a Sunday, update it to 9am of the upcoming Monday.
To simplify matters, I'm not considering holidays. All Mondays-Fridays 9am to 5pm are considered work hours.
Any suggestions how I should do it?