update_enhanced_task_status

Function update_enhanced_task_status 

Source
pub fn update_enhanced_task_status(
    contents: &str,
    task_id: &str,
    new_status: TaskStatus,
    now: DateTime<Local>,
) -> String
Expand description

Update the status and “Updated At” metadata of an enhanced-format task block.

Locates the task block whose heading starts with ### and contains the given task_id (e.g., ### Task 123: or ### 123:), replaces or inserts the - **Status**: ... and - **Updated At**: YYYY-MM-DD lines as needed, and returns the modified file contents (ensuring a trailing newline).

§Examples

use chrono::{Local, TimeZone};
use ito_domain::tasks::{TaskStatus, update_enhanced_task_status};
let contents = "## Project\n\n### Task 42: Example task\n- **Status**: [ ] pending\n";
let now = Local.with_ymd_and_hms(2025, 2, 1, 0, 0, 0).unwrap();
let out = update_enhanced_task_status(contents, "42", TaskStatus::Complete, now);
assert!(out.contains("- **Status**: [x] complete"));
assert!(out.contains("- **Updated At**: 2025-02-01"));