date managermaent fix to use local for comparisons.
This commit is contained in:
+5
-5
@@ -38,7 +38,7 @@ export interface Task {
|
|||||||
export const checkRecurringTasks = () => {
|
export const checkRecurringTasks = () => {
|
||||||
const tasks = store.tasks;
|
const tasks = store.tasks;
|
||||||
const nowObj = new Date();
|
const nowObj = new Date();
|
||||||
const todayStr = nowObj.toISOString().split('T')[0];
|
const todayStr = nowObj.toLocaleDateString('en-CA'); // YYYY-MM-DD in local time
|
||||||
|
|
||||||
tasks.forEach(task => {
|
tasks.forEach(task => {
|
||||||
if (!task.completed || !task.recurrence) return;
|
if (!task.completed || !task.recurrence) return;
|
||||||
@@ -51,14 +51,14 @@ export const checkRecurringTasks = () => {
|
|||||||
|
|
||||||
// Check if we already reset it today/this cycle
|
// Check if we already reset it today/this cycle
|
||||||
if (lastUncompleted) {
|
if (lastUncompleted) {
|
||||||
const lastDate = new Date(lastUncompleted).toISOString().split('T')[0];
|
const lastDate = new Date(lastUncompleted).toLocaleDateString('en-CA');
|
||||||
if (lastDate === todayStr) return; // Already reset today
|
if (lastDate === todayStr) return; // Already reset today
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check 'updated' date. If it was marked completed TODAY, don't reset immediately.
|
// Also check 'updated' date. If it was marked completed TODAY, don't reset immediately.
|
||||||
// We only reset if the completion happened BEFORE the current cycle trigger.
|
// We only reset if the completion happened BEFORE the current cycle trigger.
|
||||||
// E.g. Completed yesterday, today is a new day -> Reset.
|
// E.g. Completed yesterday, today is a new day -> Reset.
|
||||||
const updatedDate = new Date(task.updated).toISOString().split('T')[0];
|
const updatedDate = new Date(task.updated).toLocaleDateString('en-CA');
|
||||||
if (updatedDate === todayStr) {
|
if (updatedDate === todayStr) {
|
||||||
// If manual loop: user completes it, we shouldn't immediately uncomplete it.
|
// If manual loop: user completes it, we shouldn't immediately uncomplete it.
|
||||||
// But what if it's supposed to be uncompleted today?
|
// But what if it's supposed to be uncompleted today?
|
||||||
@@ -210,8 +210,8 @@ export const matchesFilter = (task: Task) => {
|
|||||||
|
|
||||||
// Edited Today
|
// Edited Today
|
||||||
if (f.editedToday) {
|
if (f.editedToday) {
|
||||||
const today = new Date().toISOString().split('T')[0];
|
const today = new Date().toLocaleDateString('en-CA');
|
||||||
const updated = new Date(task.updated).toISOString().split('T')[0];
|
const updated = new Date(task.updated).toLocaleDateString('en-CA');
|
||||||
if (today !== updated) return false;
|
if (today !== updated) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user