Fix todo today only when sunday
parent
7cb32c5788
commit
a339329deb
|
@ -15,6 +15,7 @@
|
||||||
let numberFormat = Intl.NumberFormat();
|
let numberFormat = Intl.NumberFormat();
|
||||||
let adding = false;
|
let adding = false;
|
||||||
let todayOnly = false;
|
let todayOnly = false;
|
||||||
|
let isSunday = false;
|
||||||
let today = getCurrentDay();
|
let today = getCurrentDay();
|
||||||
let summary = [];
|
let summary = [];
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@
|
||||||
|
|
||||||
function toggleTodayOnly() {
|
function toggleTodayOnly() {
|
||||||
today = getCurrentDay();
|
today = getCurrentDay();
|
||||||
|
isSunday = today === 'sunday';
|
||||||
todayOnly = !todayOnly;
|
todayOnly = !todayOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@
|
||||||
async function updateSummary() {
|
async function updateSummary() {
|
||||||
summary = $todos.reduce((prev, current) => {
|
summary = $todos.reduce((prev, current) => {
|
||||||
for (const [id, amount] of Object.entries(current.resources)) {
|
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) {
|
if (prev[id] === undefined) {
|
||||||
prev[id] = 0;
|
prev[id] = 0;
|
||||||
|
|
|
@ -20,7 +20,7 @@ const weekdays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'frida
|
||||||
export const getCurrentDay = () => {
|
export const getCurrentDay = () => {
|
||||||
const time = dayjs().utcOffset(timeOffset[get(server)]);
|
const time = dayjs().utcOffset(timeOffset[get(server)]);
|
||||||
let day = time.day();
|
let day = time.day();
|
||||||
if (time.hour() > 0 && time.hour() < 4) {
|
if (time.hour() >= 0 && time.hour() < 4) {
|
||||||
day -= 1;
|
day -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue