I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation.
- I work every day from Monday to Friday, totalling 38.5 hours, starting at 9am and ending at 6pm.
- Every day - except Friday - I get a lunch break from 1:00pm to 1:30pm. On Fridays I do not get a lunch break, but get off at 1:30pm instead. Note that these lunch breaks do not add to work time.
- If I check the time during the weekend (Friday after 1:30pm, Saturday or Sunday), I don't want to know about next week yet - it should tell me that zero hours are remaining instead.
Given an input date, calculate the number of work hours remaining until the weekend is here (on Friday at 1:30pm). You can assume that the input hours will range from 0 to 23, and the minutes will only ever be 0 or 30, which means that you will not have to calculate fractions other than .5.
Rules
- This is code-golf, the shortest answer, in bytes, wins.
- As usual, standard loopholes are forbidden.
- Input may be received in any reasonable datetime format. Timestamps, date strings, date objects, et cetera are all allowed. You can also directly take the input as the day of the week (indexed with Sunday as 0), the hours and the minutes.
- Output may be written directly to
stdout
or returned as a string or numeric. Printing with trailing newlines is allowed.
Test Cases
Fri May 21 2021 09:00:00 -> 4.5
Sun Jul 25 2021 16:00:00 -> 0
Mon Aug 23 2021 04:00:00 -> 38.5
Sat Nov 06 2021 08:00:00 -> 0
Thu Oct 14 2021 10:30:00 -> 11.5
Tue Dec 07 2021 14:30:00 -> 25
Fri Jan 21 2022 00:00:00 -> 4.5
Formatted as full date strings for convencience - you do not need to use this format, check the input rules.