diff options
-rw-r--r-- | src/main.odin | 4 | ||||
-rw-r--r-- | src/time.odin | 25 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/main.odin b/src/main.odin index 2030c2f..36a1c2f 100644 --- a/src/main.odin +++ b/src/main.odin @@ -3,10 +3,10 @@ package main import "core:fmt" main :: proc() { - test() + //test() new_workday({0, 0, 1, 1, 1}, {00, 08, 5, 5, 2023}, - {00, 23, 5, 5, 2023}, + {00, 07, 6, 5, 2023}, {30, 21, 5, 5, 2023}) } diff --git a/src/time.odin b/src/time.odin index 6acfc20..56d7425 100644 --- a/src/time.odin +++ b/src/time.odin @@ -47,7 +47,7 @@ Workday :: struct { wrap : Moment, planned_wrap : Moment, - blocks : [15]Timeblock, + blocks : [12]Timeblock, total_timeblocks : int, } @@ -71,7 +71,8 @@ new_workday :: proc(previous_wrap : Moment, // Paragraph 6.7 says that up to 2 hours of unused warned overtime counts as worktime, // 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) - max(clamp(sub(planned_wrap, {0, 1, 0}), wrap, add(planned_wrap, {0, 2, 0})), + max(clamp(sub(planned_wrap, {0, 1, 0}), wrap, add(wrap, {0, 2, 0})), + //max(sub(planned_wraptime, {0,1,0}), wrap), add(call, {0, 4, 0})), 0, ""} // ^ Minimum 4 hour day ^ @@ -90,7 +91,7 @@ new_workday :: proc(previous_wrap : Moment, add(call, {0, 14, 0}), // The 14-hour mark {0, 22, call.day, call.month, call.year}, // 22:00 in the evening add({0, 23, call.day, call.month, call.year}, {0, 1, 0}), // Midnight - add({0, 22, call.day, call.month, call.year}, {0, 7, 0}), // 06:00 the next morning + add({0, 23, call.day, call.month, call.year}, {0, 7, 0}), // 06:00 the next morning } // Eliminate planned wrap, if it occurs within normal 8-hour period. @@ -102,23 +103,31 @@ new_workday :: proc(previous_wrap : Moment, splitpoints_sorted: [sp_length]Moment = splitpoints slice.sort_by(splitpoints_sorted[:], lessMoment) + + for each_point, i in splitpoints_sorted { + fmt.printf("Splitpoint %2i: %s\n", i+1, toString(each_point)) + } working_block: Timeblock = initial_block + fmt.println("working_block: ", toString(working_block)) j: int = 0 - for each_moment in splitpoints_sorted { + for each_point in splitpoints_sorted { // If each splitpoint moment is within the workday, and is not equal to the start of the current block - if sortable(each_moment) > sortable(call) && sortable(each_moment) < sortable(wrap) && each_moment != initial_block.start { - blocks[j], working_block = timesplit(working_block, each_moment) + if sortable(each_point) > sortable(call) && + sortable(each_point) < sortable(wrap) && + each_point != working_block.start { + + blocks[j], working_block = timesplit(working_block, each_point) j += 1 - fmt.println("Split and wrote:", j) + //fmt.println("Split and wrote:", j) } } blocks[j] = working_block j += 1 total_timeblocks = j - slice.sort_by(blocks[:], lessTimeblock) + //slice.sort_by(blocks[:], lessTimeblock) for each_block, i in blocks { fmt.printf("Block %2i: %s\n", i+1, toString(each_block)) |