aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSanJacobs2022-07-12 23:08:20 +0200
committerSanJacobs2022-07-12 23:08:20 +0200
commit62866cac4eb109490ad1d79a3295a3848da8c134 (patch)
treebcba9c3c305a7d79e2555d72a70a6b757f710e9a /src
parent0163ec13c0e4efe890f8c79a838a26acffa0088e (diff)
downloadsatscalc-62866cac4eb109490ad1d79a3295a3848da8c134.tar.gz
satscalc-62866cac4eb109490ad1d79a3295a3848da8c134.tar.bz2
satscalc-62866cac4eb109490ad1d79a3295a3848da8c134.zip
Adding and slicing workdays is now functional
As well as adding dayrate, and thereby hourly rate, but pricing the timeblocks is not handled yet.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.cpp43
-rwxr-xr-xsrc/time.cpp15
2 files changed, 39 insertions, 19 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 2af0702..d3b0023 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -48,24 +48,39 @@ int main(int argc, char* argv[])
std::cout << "-----\nStep 1: Adding the days\n\n";
- while(1) {
- std::cout << "Filling in a test-day, and that's it.\n";
- std::cout << "Storing multiple workdays in an efficient way will be figured out later." << std::endl;
+ std::cout << "How many days do you want to submit?" << std::endl;
+ int number_of_days;
+ // std::cin >> number_of_days;
+ number_of_days = 3; // Just here for debugging
+ std::vector<workday> workdays;
+
+ moment previous_wrap{0, 16, 20, 11, 1000}; // Set to a long time ago
+
+ for(int day=0; day<number_of_days; day++) {
- workday test_day({0, 0, 1, 1, 1000},
- {0, 8, 20, 11, 2022},
- {0, 21, 20, 11, 2022},
- {0, 18, 20, 11, 2022});
+ std::cout << "\n - DAY " << day+1 << "-\nCalltime:\n";
+ moment calltime = timeinput();
+ std::cout << "\nWraptime:\n";
+ moment wraptime = timeinput();
+ std::cout << "\nPlanned wraptime:\n";
+ moment planned_wraptime = timeinput();
- std::cout << "\nCalltime: " << timeprint(test_day.call) << "\n";
- std::cout << "Wraptime: " << timeprint(test_day.wrap) << "\n";
- std::cout << "Planned wrap: " << timeprint(test_day.planned_wrap) << "\n\n";
+ workdays.push_back({previous_wrap,
+ calltime,
+ wraptime,
+ planned_wraptime});
- for(int i=0; i<test_day.total_timeblocks; i++) {
- std::cout << "Segment " << i << ": " << timeprint(test_day.blocks[i]) << std::endl;
- }
+ workday* current_workday = &workdays[day];
- break;
+ std::cout << "\nCalltime: " << timeprint(current_workday->call) << "\n";
+ std::cout << "Wraptime: " << timeprint(current_workday->wrap) << "\n";
+ std::cout << "Planned wrap: " << timeprint(current_workday->planned_wrap) << "\n\n";
+
+ for(int i=0; i<current_workday->total_timeblocks; i++) {
+ std::cout << "Timeblock " << i << ": " << timeprint(current_workday->blocks[i])
+ << ". Total hours: " << current_workday->blocks[i].hourcount() << std::endl;
+ }
+ previous_wrap = wraptime;
}
return 0;
diff --git a/src/time.cpp b/src/time.cpp
index 37c0f5f..98a5482 100755
--- a/src/time.cpp
+++ b/src/time.cpp
@@ -145,7 +145,6 @@ workday::workday(const moment& previous_wrap,
(moment){0, 22, call.day, call.month, call.year}, // 22:00 in the evening
(moment){0, 23, call.day, call.month, call.year}+(delta){0, 1, 0}, // Midnight
(moment){0, 23, call.day, call.month, call.year}+(delta){0, 7, 0}, // 6, next morning
-
};
int j = 0;
@@ -153,12 +152,17 @@ workday::workday(const moment& previous_wrap,
const moment* each_moment = &splitpoints[i];
if(*each_moment > call && *each_moment < wrap) {
blocks[j++] = timesplit(initial_block, *each_moment);
- // TODO: Timesplit's input and return have been flipped, so check if this works
}
}
blocks[j++] = initial_block;
total_timeblocks = j;
+
+ // TODO: This is really ugly, but I think what I need to do here is:
+ // Loop over the whole thing again to set the valuefactors of every timeblock.
+
+
+
}
@@ -313,19 +317,20 @@ int days_in(int month, int year) {
}
// TODO: Add checks for correct formatting, and ask for new input if wrong
-moment timeinput(int or_year, int or_month, int or_day) {
+moment timeinput(const moment) {
char input_string[5];
std::cout << "Input time\nHHMM (24-hour format, no space)\n";
std::cin >> input_string;
moment output{std::stoi(std::string(std::string(1, input_string[2])+input_string[3])),
std::stoi(std::string(std::string(1, input_string[0])+input_string[1])),
or_day, or_month, or_year};
- // This is retarded
+ // This is retarded and needs to be completely replaced
return output;
}
+
moment timeinput() {
char input_string[17];
- std::cout << "Input date and time\nYEAR MM DD hh mm (24-hour format, use spaces)\n";
+ std::cout << "YEAR MM DD hh mm (24-hour format, use spaces)\n";
std::cin.getline(input_string, 17);
// This uglyness is just how you use strtok() to split a string, apparently