@@ -295,7 +295,9 @@ public function get_task_id( $task_data = [] ) {
295295 $ parts [] = $ task_data ['target_taxonomy ' ] ?? false ;
296296 // If the task is repetitive, add the date as the last part (format: YYYYWW, e.g., 202542 for week 42 of 2025).
297297 // This creates a new task instance each week for repetitive tasks.
298- $ parts [] = $ this ->is_repetitive () ? \gmdate ( 'YW ' ) : false ;
298+ // Note: We use 'oW' format (ISO year + ISO week) instead of 'YW' to handle year boundaries correctly.
299+ // For example, Dec 29, 2025 is ISO week 01 of 2026, so 'oW' returns '202601' while 'YW' would incorrectly return '202501'.
300+ $ parts [] = $ this ->is_repetitive () ? \gmdate ( 'oW ' ) : false ;
299301
300302 // Remove empty parts to keep IDs clean.
301303 $ parts = \array_filter ( $ parts );
@@ -447,7 +449,7 @@ public function is_task_relevant() {
447449 * - Returns the task object if completed, false otherwise
448450 *
449451 * Repetitive tasks:
450- * - Must be completed within the same week they were created (using YW format: year + week number)
452+ * - Must be completed within the same week they were created (using oW format: ISO year + ISO week number)
451453 * - For example, a task created in week 42 of 2025 must be completed in 2025W42
452454 * - This prevents tasks from previous weeks being marked as complete
453455 * - Allows child classes to add completion data (e.g., post_id for "create post" tasks)
@@ -483,8 +485,8 @@ public function evaluate_task( $task_id ) {
483485 $ task ->provider &&
484486 $ task ->provider ->slug === $ this ->get_provider_id () &&
485487 \DateTime::createFromFormat ( 'Y-m-d H:i:s ' , $ task ->post_date ) &&
486- // Check if the task was created in the current week (YW format: e.g., 202542 = week 42 of 2025).
487- \gmdate ( 'YW ' ) === \gmdate ( 'YW ' , \DateTime::createFromFormat ( 'Y-m-d H:i:s ' , $ task ->post_date )->getTimestamp () ) && // @phpstan-ignore-line
488+ // Check if the task was created in the current week (oW format: ISO year + ISO week, e.g., 202542 = week 42 of 2025).
489+ \gmdate ( 'oW ' ) === \gmdate ( 'oW ' , \DateTime::createFromFormat ( 'Y-m-d H:i:s ' , $ task ->post_date )->getTimestamp () ) && // @phpstan-ignore-line
488490 $ this ->is_task_completed ( \progress_planner ()->get_suggested_tasks ()->get_task_id_from_slug ( $ task ->post_name ) )
489491 ) {
490492 // Allow adding more data, for example in case of 'create-post' tasks we are adding the post_id.
@@ -599,7 +601,7 @@ public function get_task_details( $task_data = [] ) {
599601 'parent ' => $ this ->get_parent (),
600602 'priority ' => $ this ->get_priority (),
601603 'points ' => $ this ->get_points (),
602- 'date ' => \gmdate ( 'YW ' ),
604+ 'date ' => \gmdate ( 'oW ' ),
603605 'url ' => $ this ->get_url_with_data ( $ task_data ),
604606 'url_target ' => $ this ->get_url_target (),
605607 'link_setting ' => $ this ->get_link_setting (),
0 commit comments