MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / extractTimeblocksFromNote

Function extractTimeblocksFromNote

src/utils/helpers.ts:693–724  ·  view source on GitHub ↗
(content: string, path: string)

Source from the content-addressed store, hash-verified

691 * Extracts and validates timeblocks from daily note frontmatter
692 */
693export 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

Callers 2

helpers.test.tsFile · 0.90

Calls 4

validateTimeBlockFunction · 0.85
warnMethod · 0.80
errorMethod · 0.80
extractFrontmatterFunction · 0.70

Tested by

no test coverage detected