From a38359917d770156d8a5d5e8123074c54c8a0ab7 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Thu, 4 Aug 2022 12:13:55 +0200 Subject: Added minimum day length and unused overtime rule --- src/time.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/time.cpp') diff --git a/src/time.cpp b/src/time.cpp index 4f14772..11b4336 100755 --- a/src/time.cpp +++ b/src/time.cpp @@ -127,8 +127,16 @@ workday::workday(const moment& previous_wrap, call = calltime; wrap = wraptime; planned_wrap = planned_wraptime; - timeblock initial_block{call, wrap}; - moment splitpoints[10]{ // --$-- Points where the price may change --$-- // + timeblock initial_block{call, + std::max( + // 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) + std::clamp(planned_wrap-(delta){0, 1, 0}, wraptime, planned_wraptime+(delta){0, 2, 0}), + call+(delta){0, 4, 0})}; + // ^ Minimum 4 hour day ^ + + const int sp_length = 10; + moment splitpoints[sp_length]{ // --$-- Points where the price may change --$-- // // NOTE: Maybe this should also contain the valuefactor associated with the split. // Probably the valuefactor leading up to the splitpoint, not the one after. @@ -154,12 +162,12 @@ workday::workday(const moment& previous_wrap, splitpoints[5] = splitpoints[3]; } - moment splitpoints_sorted[10]; - std::copy(splitpoints, splitpoints+10, splitpoints_sorted); - std::sort(splitpoints_sorted, splitpoints_sorted + 10); + moment splitpoints_sorted[sp_length]; + std::copy(splitpoints, splitpoints+sp_length, splitpoints_sorted); + std::sort(splitpoints_sorted, splitpoints_sorted + sp_length); int j = 0; - for(int i = 0; i<10; i++) { + for(int i = 0; i