feat: added time to shift

This commit is contained in:
2026-08-07 13:50:21 +03:00
parent fc56186d99
commit bc88882ec4
2 changed files with 24 additions and 2 deletions
+1
View File
@@ -23,6 +23,7 @@
<div class="vblock"> <div class="vblock">
<div class="hblock"> <div class="hblock">
<div class="next-break jetbrains-mono" id="nextBreak"></div> <div class="next-break jetbrains-mono" id="nextBreak"></div>
<div class="next-break secondary jetbrains-mono" id="shift1End"></div>
<div class="next-break secondary jetbrains-mono" id="endOfDay"></div> <div class="next-break secondary jetbrains-mono" id="endOfDay"></div>
</div> </div>
</div> </div>
+23 -2
View File
@@ -17,7 +17,10 @@ const WEEKEND_BREAKS = [
const WEEKDAY_END_OF_DAY = "23:00"; const WEEKDAY_END_OF_DAY = "23:00";
const WEEKEND_END_OF_DAY = "22: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 breakNodes = [];
let lastDayKey = ""; let lastDayKey = "";
@@ -55,10 +58,19 @@ function getWorkDayEndForToday(now) {
return day === 0 || day === 6 ? WEEKEND_END_OF_DAY : WEEKDAY_END_OF_DAY; 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) { function getEndOfDayMs(now) {
return breakMsForToday(getWorkDayEndForToday(now), now); return breakMsForToday(getWorkDayEndForToday(now), now);
} }
function getShift1EndMs(now) {
return breakMsForToday(getShift1EndForToday(now), now);
}
function formatDuration(ms) { function formatDuration(ms) {
const totalSeconds = Math.floor(ms / 1000); const totalSeconds = Math.floor(ms / 1000);
const h = Math.floor(totalSeconds / 3600); const h = Math.floor(totalSeconds / 3600);
@@ -265,7 +277,13 @@ function updateNextBreak() {
const endOfDayMs = getEndOfDayMs(now); const endOfDayMs = getEndOfDayMs(now);
const timeUntilEndOfDay = Math.max(0, endOfDayMs - now.getTime()); const timeUntilEndOfDay = Math.max(0, endOfDayMs - now.getTime());
endOfDayEl.textContent = 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(); scheduleNextBreakTick();
} }
@@ -292,6 +310,7 @@ function init() {
dateEl = document.getElementById("currentDate"); dateEl = document.getElementById("currentDate");
nextBreakEl = document.getElementById("nextBreak"); nextBreakEl = document.getElementById("nextBreak");
endOfDayEl = document.getElementById("endOfDay"); endOfDayEl = document.getElementById("endOfDay");
shift1EndEl = document.getElementById("shift1End");
buildBreakBlocks(); buildBreakBlocks();
buildCalendar(); buildCalendar();
@@ -314,7 +333,9 @@ if (typeof module !== "undefined" && module.exports) {
module.exports = { module.exports = {
getBreaksForToday, getBreaksForToday,
getWorkDayEndForToday, getWorkDayEndForToday,
getShift1EndForToday,
getEndOfDayMs, getEndOfDayMs,
getShift1EndMs,
breakTimeToMinutes, breakTimeToMinutes,
formatDuration, formatDuration,
}; };