aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSanJacobs2023-05-18 15:47:01 +0200
committerSanJacobs2023-05-18 15:47:01 +0200
commitf429f940d4c28c79ac778d1f99f200e8bc91e4ca (patch)
treebd9d126eabc94cbe4765387fc876434d18b273d6 /src
parentd2b654b37da8fd7dcc29f01c4d654b008ff724f7 (diff)
downloadsatscalc-f429f940d4c28c79ac778d1f99f200e8bc91e4ca.tar.gz
satscalc-f429f940d4c28c79ac778d1f99f200e8bc91e4ca.tar.bz2
satscalc-f429f940d4c28c79ac778d1f99f200e8bc91e4ca.zip
Fixed some crucial bugs, did some minor improvements
Diffstat (limited to 'src')
-rw-r--r--src/main.odin4
-rw-r--r--src/time.odin25
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))