From 0a51fac9f3a60ecfa647ad7aeb179c310dca3606 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Tue, 2 Jan 2024 12:00:47 +0100 Subject: Fixed 4-hour minimum bug referenced in 5f685eaabf4 --- src/time.cpp | 7 ++++++- src/time.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/time.cpp b/src/time.cpp index 0aa7bd0..4f15cd5 100755 --- a/src/time.cpp +++ b/src/time.cpp @@ -115,6 +115,11 @@ std::ostream& operator<<(std::ostream& stream, const delta& other) { return stream; } +moment timemax(moment a, moment b) { + if (a > b) return a; + return b; +} + // // --- CONSTRUCTORS --- @@ -173,7 +178,7 @@ workday::workday(const moment& previous_wrap, const moment* each_moment = &splitpoints_sorted[i]; //std::cout << "Splitting: " << timeprint(*each_moment) << "\t\tJ: " << j << "\t\tI: " << i << std::endl; // If each splitpoint moment is within the workday, and is not equal to the start of the current block - if(*each_moment > call && *each_moment < wrap && *each_moment != initial_block.start) { + if(*each_moment > call && *each_moment < timemax(wrap, call+(delta){0,4,0}) && *each_moment != initial_block.start) { blocks[j++] = timesplit(initial_block, *each_moment); } } diff --git a/src/time.h b/src/time.h index 52562bd..1116969 100755 --- a/src/time.h +++ b/src/time.h @@ -110,3 +110,4 @@ moment timeinput(moment input_moment); moment timeinput(); // TODO: Completely re-write timeinput to be beautiful and enforce valid dates +moment timemax(moment a, moment b); \ No newline at end of file -- cgit v1.2.1