-- tracker.reset — wipe today's entries (and the open session). local lang = jarvis.context.language or "ru" local now = jarvis.context.time.timestamp or os.time() local t = jarvis.context.time local h = tonumber(t.hour) or 0 local mi = tonumber(t.minute) or 0 local s = tonumber(t.second) or 0 local today_start = now - (h * 3600 + mi * 60 + s) local data = jarvis.state.get("data") or {} local sessions = data.sessions or {} local kept = {} local dropped = 0 for _, sess in ipairs(sessions) do local sstart = tonumber(sess.start) or 0 if sstart < today_start then table.insert(kept, sess) else dropped = dropped + 1 end end local had_open = data.current_session_start ~= nil data.sessions = kept data.current_session_start = nil jarvis.state.set("data", data) if dropped == 0 and not had_open then return jarvis.cmd.ok(lang == "ru" and "Сегодня сбрасывать нечего, сэр." or "Nothing to reset today, sir.") end local confirm if lang == "ru" then confirm = "Подтверждаю: трекер за сегодня очищен" if dropped > 0 then local sw local n10 = dropped % 10; local n100 = dropped % 100 if n100 >= 11 and n100 <= 14 then sw = "сессий" elseif n10 == 1 then sw = "сессия" elseif n10 >= 2 and n10 <= 4 then sw = "сессии" else sw = "сессий" end confirm = confirm .. ", удалено " .. dropped .. " " .. sw end if had_open then confirm = confirm .. ", активный отсчёт остановлен" end confirm = confirm .. "." else confirm = "Confirmed: tracker for today cleared" if dropped > 0 then confirm = confirm .. ", " .. dropped .. " session" .. (dropped == 1 and "" or "s") .. " removed" end if had_open then confirm = confirm .. ", running session stopped" end confirm = confirm .. "." end return jarvis.cmd.ok(confirm)