Tell the solution to implement the display of the current work shift on schedule 3-2.
Conditions:
- Three working days, two days off;
- Three shifts 1 - from 23:00 (before the current day of the shift, the main day is listed as from 00:00 to 07:00) to 07:00 , 2 - from 07:00 to 15:00 , 3 - from 15:00 to 23:00 ;
- Total duty shift 5 - "A", "B", "C", "G", "D".
For the beginning, you can take from 01/01/2016 with the following values (B - output):
Change "A": В В 1 1 1 В В 3 3 3 В В 2 2 2 (further in a circle);
Change “B”: В 3 3 3 В В 2 2 2 В В 1 1 1 В;
Change "In": 2 2 2 В 1 1 1 В В 3 3 3 В В;
Change “G”: 1 1 В В 3 3 3 В В 2 2 2 В В 1;
Change "D": 3 IN 2 2 2 IN 1 1 1 IN 3 3.
There is a solution that determines the number of the shift (including the hour before the current day).
DateNow = new Date(); var time = ("0" + DateNow.getHours()).substr(-2) + ':' + ("0" + DateNow.getMinutes()).substr(-2); window.setTimeout(arguments.callee, 15000); // определяем номер смены, в зависимости от времени var day = DateNow.getDate(); var shift = 1; //shift - смена if (DateNow.getHours() >= 7) { if (DateNow.getHours() >= 15) { if (DateNow.getHours() < 23) shift = 3; else { DateNow.setDate(DateNow.getDate() + 1); day = DateNow.getDate(); } } else shift = 2; }