Fix todo today only when sunday

pull/1/head
I Made Setia Baruna 2021-01-10 01:04:34 +08:00
parent 7cb32c5788
commit a339329deb
2 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@
let numberFormat = Intl.NumberFormat();
let adding = false;
let todayOnly = false;
let isSunday = false;
let today = getCurrentDay();
let summary = [];
@ -60,6 +61,7 @@
function toggleTodayOnly() {
today = getCurrentDay();
isSunday = today === 'sunday';
todayOnly = !todayOnly;
}
@ -87,7 +89,7 @@
async function updateSummary() {
summary = $todos.reduce((prev, current) => {
for (const [id, amount] of Object.entries(current.resources)) {
if (todayOnly && itemList[id].day && !itemList[id].day.includes(today)) continue;
if (!isSunday && todayOnly && itemList[id].day && !itemList[id].day.includes(today)) continue;
if (prev[id] === undefined) {
prev[id] = 0;

View File

@ -20,7 +20,7 @@ const weekdays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'frida
export const getCurrentDay = () => {
const time = dayjs().utcOffset(timeOffset[get(server)]);
let day = time.day();
if (time.hour() > 0 && time.hour() < 4) {
if (time.hour() >= 0 && time.hour() < 4) {
day -= 1;
}