(content: string, path: string)
| 691 | * Extracts and validates timeblocks from daily note frontmatter |
| 692 | */ |
| 693 | export function extractTimeblocksFromNote(content: string, path: string): TimeBlock[] { |
| 694 | try { |
| 695 | const frontmatter = extractFrontmatter(content) as DailyNoteFrontmatter; |
| 696 | |
| 697 | if (!frontmatter || !frontmatter.timeblocks || !Array.isArray(frontmatter.timeblocks)) { |
| 698 | return []; |
| 699 | } |
| 700 | |
| 701 | const validTimeblocks: TimeBlock[] = []; |
| 702 | |
| 703 | for (const timeblock of frontmatter.timeblocks) { |
| 704 | if (validateTimeBlock(timeblock)) { |
| 705 | validTimeblocks.push(timeblock); |
| 706 | } else { |
| 707 | tasknotesLogger.warn(`Invalid timeblock in ${path}:`, { |
| 708 | category: "validation", |
| 709 | operation: "invalid-timeblock", |
| 710 | details: { value: timeblock }, |
| 711 | }); |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | return validTimeblocks; |
| 716 | } catch (error) { |
| 717 | tasknotesLogger.error(`Error extracting timeblocks from ${path}:`, { |
| 718 | category: "internal", |
| 719 | operation: "extracting-timeblocks", |
| 720 | error: error, |
| 721 | }); |
| 722 | return []; |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * Converts a timeblock to a calendar event format |
no test coverage detected