From 9e169b92e803ae154fb0d94240c73df31c200aa3 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Fri, 19 Sep 2025 18:30:37 +0200 Subject: Substring filter --- time.odin | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'time.odin') diff --git a/time.odin b/time.odin index 4c264b4..f98f0ff 100644 --- a/time.odin +++ b/time.odin @@ -41,6 +41,7 @@ Timeblock :: struct { end : Moment, value : f32, reason : string, + title : string, } Fractionpair :: struct { @@ -92,7 +93,7 @@ new_workday :: proc(previous_wrap : Moment, // though so that at least one hour of the unused overtime is not counted. // (It's unclear if an 8-hour day that ends 3 hours in counts as having 5 hours of unused overtime) time_max(time_clamp(sub(planned_wrap, {0, 1, 0}), wrap, add(wrap, {0, 2, 0})), - add(call, {0, 4, 0})), 1, ""} + add(call, {0, 4, 0})), 1, "", ""} // ^ Minimum 4 hour day ^ // BUG: I think this is causing a bug where if the day ends at 6 and gets extended, @@ -358,8 +359,8 @@ timesplit :: proc(block: Timeblock, splitpoint: Moment) -> (first_half: Timebloc return } - first_half = {block.start, splitpoint, block.value, block.reason} - second_half = {splitpoint, block.end, block.value, block.reason} + first_half = {block.start, splitpoint, block.value, block.reason, ""} + second_half = {splitpoint, block.end, block.value, block.reason, ""} return } @@ -445,6 +446,12 @@ importICS :: proc(path: string, verbose: bool = false) -> ([dynamic]Timeblock, b c.end.year = strconv.atoi(line[ll-15:ll-11]) } + if line[0:min(8, len(line))]=="SUMMARY:" { + if verbose do fmt.println("Found a SUMMARY!") + if verbose do fmt.println(line) + ll := len(line) + c.title = line[8:ll] + } // TODO: This is checking if the years are 0 to make sure it hasn't read from // from a line containing "DTSTART;VALUE" instead of "DTSTART;TZID" @@ -689,8 +696,8 @@ momentToString :: proc(moment: Moment) -> (output: string) { } timeblockToString :: proc(block: Timeblock) -> (output: string) { using block - s: [3]string = {toString(start), " -> ", toString(end)} - output = strings.concatenate(s[:]) + s: [5]string = {} + output = fmt.aprintf("%s -> %s | %0.3f hrs | %s", toString(start), toString(end), hourcount(block), title) return } toString :: proc{deltaToString, momentToString, timeblockToString} @@ -725,7 +732,7 @@ popBlock :: proc(workday: ^Workday, index: int, count: int = 1) { blocks[i] = blocks[i+count] } for i in len(blocks)-count-1..