diff --git a/src/index.html b/src/index.html
index fba0b3b..b681845 100644
--- a/src/index.html
+++ b/src/index.html
@@ -23,6 +23,7 @@
diff --git a/src/index.js b/src/index.js
index d33c1bf..29b5800 100644
--- a/src/index.js
+++ b/src/index.js
@@ -17,7 +17,10 @@ const WEEKEND_BREAKS = [
const WEEKDAY_END_OF_DAY = "23:00";
const WEEKEND_END_OF_DAY = "22:00";
-let clockEl, dateEl, nextBreakEl, endOfDayEl;
+const WEEKDAY_SHIFT1_END = "15:00";
+const WEEKEND_SHIFT1_END = "15:30";
+
+let clockEl, dateEl, nextBreakEl, endOfDayEl, shift1EndEl;
let breakNodes = [];
let lastDayKey = "";
@@ -55,10 +58,19 @@ function getWorkDayEndForToday(now) {
return day === 0 || day === 6 ? WEEKEND_END_OF_DAY : WEEKDAY_END_OF_DAY;
}
+function getShift1EndForToday(now) {
+ const day = now.getDay();
+ return day === 0 || day === 6 ? WEEKEND_SHIFT1_END : WEEKDAY_SHIFT1_END;
+}
+
function getEndOfDayMs(now) {
return breakMsForToday(getWorkDayEndForToday(now), now);
}
+function getShift1EndMs(now) {
+ return breakMsForToday(getShift1EndForToday(now), now);
+}
+
function formatDuration(ms) {
const totalSeconds = Math.floor(ms / 1000);
const h = Math.floor(totalSeconds / 3600);
@@ -265,7 +277,13 @@ function updateNextBreak() {
const endOfDayMs = getEndOfDayMs(now);
const timeUntilEndOfDay = Math.max(0, endOfDayMs - now.getTime());
endOfDayEl.textContent =
- "До конца работы · " + formatDuration(timeUntilEndOfDay);
+ "До конца рабочего дня · " + formatDuration(timeUntilEndOfDay);
+
+ const shift1Ms = getShift1EndMs(now);
+ const timeUntilShift1End = Math.max(0, shift1Ms - now.getTime());
+ shift1EndEl.textContent =
+ "До конца смены 1 (" + getShift1EndForToday(now) + ") · " +
+ formatDuration(timeUntilShift1End);
scheduleNextBreakTick();
}
@@ -292,6 +310,7 @@ function init() {
dateEl = document.getElementById("currentDate");
nextBreakEl = document.getElementById("nextBreak");
endOfDayEl = document.getElementById("endOfDay");
+ shift1EndEl = document.getElementById("shift1End");
buildBreakBlocks();
buildCalendar();
@@ -314,7 +333,9 @@ if (typeof module !== "undefined" && module.exports) {
module.exports = {
getBreaksForToday,
getWorkDayEndForToday,
+ getShift1EndForToday,
getEndOfDayMs,
+ getShift1EndMs,
breakTimeToMinutes,
formatDuration,
};