diff options
author | San Jacobs | 2023-10-15 14:59:33 +0200 |
---|---|---|
committer | San Jacobs | 2023-10-15 14:59:33 +0200 |
commit | 690d1102dedbbad955c34ba1a5ef9f4d15d82158 (patch) | |
tree | 887d6bea6a843952c7d8346a99131601f603e19f /src/time.odin | |
parent | b6dab385dbf9a626970f3673d345d0e8e6a62e1e (diff) | |
parent | 2e3a7e10756954dc5a99d617a1c0eef327d3adbb (diff) | |
download | satscalc-690d1102dedbbad955c34ba1a5ef9f4d15d82158.tar.gz satscalc-690d1102dedbbad955c34ba1a5ef9f4d15d82158.tar.bz2 satscalc-690d1102dedbbad955c34ba1a5ef9f4d15d82158.zip |
Merge branch 'oui' into odin
Diffstat (limited to 'src/time.odin')
-rw-r--r-- | src/time.odin | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/time.odin b/src/time.odin index 468f5d8..90dca49 100644 --- a/src/time.odin +++ b/src/time.odin @@ -90,7 +90,7 @@ 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(wrap, {0, 2, 0})), + time_max(time_clamp(sub(planned_wrap, {0, 1, 0}), wrap, add(wrap, {0, 2, 0})), add(call, {0, 4, 0})), 1, ""} // ^ Minimum 4 hour day ^ @@ -170,7 +170,7 @@ new_workday :: proc(previous_wrap : Moment, if getweekday(block.start) == .Sunday do upvalue(&block, 2, "Sunday") // Sundays are +100% if !(less(call, Moment{0, 7, call.day, call.month, call.year}) && - less(min(add(call, Delta{0,8,0}), wrap), Moment{0, 17, call.day, call.month, call.year} )) { + less(time_min(add(call, Delta{0,8,0}), wrap), Moment{0, 17, call.day, call.month, call.year} )) { // This was added for rule 6.11c, but in a world without a defined normal workday, // that rule is already covered already by 6.11g, so this is empty. } @@ -489,7 +489,7 @@ maxDelta :: proc(delta_a: Delta, delta_b: Delta) -> Delta { if sortable(delta_a) > sortable(delta_b) do return delta_a return delta_b } -max :: proc{maxDelta, maxMoment} +time_max :: proc{maxDelta, maxMoment} minMoment :: proc(moment_a: Moment, moment_b: Moment) -> Moment { if sortable(moment_a) < sortable(moment_b) do return moment_a @@ -499,15 +499,15 @@ minDelta :: proc(delta_a: Delta, delta_b: Delta) -> Delta { if sortable(delta_a) < sortable(delta_b) do return delta_a return delta_b } -min :: proc{minDelta, minMoment} +time_min :: proc{minDelta, minMoment} clampMoment :: proc(moment: Moment, moment_min: Moment, moment_max: Moment) -> Moment { - return min(max(moment, moment_min), moment_max) + return time_min(time_max(moment, moment_min), moment_max) } clampDelta :: proc(delta: Delta, delta_min: Delta, delta_max: Delta) -> Delta { - return min(max(delta, delta_min), delta_max) + return time_min(time_max(delta, delta_min), delta_max) } -clamp :: proc{clampMoment, clampDelta} +time_clamp :: proc{clampMoment, clampDelta} greatMoment :: proc(moment_a: Moment, moment_b: Moment) -> bool { return bool(sortable(moment_a) > sortable(moment_b)) @@ -702,6 +702,16 @@ clockprintTimeblock :: proc(block: Timeblock) -> string { } clockprint :: proc{clockprintTimeblock, clockprintMoment} +dayprintMoment :: proc(moment: Moment) -> string { + using moment + return fmt.tprintf("%4i-%2i-%2i", year, month, day) +} +dayprintTimeblock :: proc(block: Timeblock) -> string { + using block + return fmt.tprintf("%s -> %s", dayprint(start), dayprint(end)) +} +dayprint :: proc{dayprintTimeblock, dayprintMoment} + popBlock :: proc(workday: ^Workday, index: int, count: int = 1) { using workday when ODIN_DEBUG do fmt.printf("popBlock() running to remove %i block(s) from index %i\n", count, index) |