aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSan Jacobs2024-01-02 12:00:47 +0100
committerSan Jacobs2024-01-02 12:00:47 +0100
commit0a51fac9f3a60ecfa647ad7aeb179c310dca3606 (patch)
tree6d0d4b3e3c375f680edb93a2fe9ebf69c0dd5c96
parent5b3537db08f98372acdd3b5e22c42441132355c7 (diff)
downloadsatscalc-0a51fac9f3a60ecfa647ad7aeb179c310dca3606.tar.gz
satscalc-0a51fac9f3a60ecfa647ad7aeb179c310dca3606.tar.bz2
satscalc-0a51fac9f3a60ecfa647ad7aeb179c310dca3606.zip
Fixed 4-hour minimum bug referenced in 5f685eaabf4
-rwxr-xr-xsrc/time.cpp7
-rwxr-xr-xsrc/time.h1
2 files changed, 7 insertions, 1 deletions
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