aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSan Jacobs2022-08-04 11:15:32 +0200
committerSan Jacobs2022-08-04 11:15:32 +0200
commit78adbe39f0ce7b1e5a4925b4ba46165b90906231 (patch)
treecc84f0b2c8f6c95f84a5b9c74d87abd433e4505a /src
parent5782dff14768e5cf7e20091bca016013e300e433 (diff)
downloadsatscalc-78adbe39f0ce7b1e5a4925b4ba46165b90906231.tar.gz
satscalc-78adbe39f0ce7b1e5a4925b4ba46165b90906231.tar.bz2
satscalc-78adbe39f0ce7b1e5a4925b4ba46165b90906231.zip
Much more beautiful formatting
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.cpp27
-rwxr-xr-xsrc/time.cpp28
-rwxr-xr-xsrc/time.h2
3 files changed, 39 insertions, 18 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 02037b8..d1c9080 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -59,8 +59,6 @@ int main(int argc, char* argv[])
for(int day=0; day<number_of_days; day++) {
- // TODO: Asking for everything repeatedly like this is dumb,
- // and needs to be replaced with a menu system.
// TODO: Inputing the dates should be done with a custom function and layout,
// not std::cin, because it openly allows for invalid input
std::cout << "\n - DAY " << day+1 << "-\nCalltime:\n";
@@ -72,8 +70,9 @@ int main(int argc, char* argv[])
moment lunch_start = calltime+(delta){0,4,0};
moment lunch_end = lunch_start+(delta){30,0,0};
- std::cout << "\n------------- DAY " << day+1 << " -------------\n";
while(1) {
+ std::cout << "\033[2J\033[1;1H";
+ std::cout << "\n------------- DAY " << day+1 << " -------------\n";
std::cout << "[1] Calltime: " << timeprint(calltime) << "\n";
std::cout << "[2] Wraptime: " << timeprint(wraptime) << "\n";
std::cout << "[3] Planned wrap: " << timeprint(planned_wraptime) << "\n";
@@ -86,6 +85,7 @@ int main(int argc, char* argv[])
std::cin >> input_number;
std::cin.ignore();
+ std::cout << "\n";
switch (input_number) {
case 0:
goto done;
@@ -114,15 +114,6 @@ int main(int argc, char* argv[])
}
done:
- //std::cout << "\nWraptime:\n";
- //moment wraptime = timeinput(calltime);
- //std::cout << "\nPlanned wraptime:\n";
- //moment planned_wraptime = timeinput(calltime);
- //std::cout << "\nLunch start:\n";
- //moment lunch_start = timeinput(calltime);
- //std::cout << "\nLunch end:\n";
- //moment lunch_end = timeinput(calltime);
-
workdays.push_back({previous_wrap,
calltime,
wraptime,
@@ -141,22 +132,28 @@ done:
<< ". Total hours: " << current_workday->blocks[i].hourcount()
<< "\t Valuefactor: " << current_workday->blocks[i].valuefactor << std::endl;
}
+
+ // This assumes that the user is entering things chronologically, which they may not be
previous_wrap = wraptime;
+ std::cout << "\033[2J\033[1;1H";
}
+ std::cout << "\n\n\n -+-+-+-+-+-+-+- CALCULATION -+-+-+-+-+-+-+-\n\n";
+ std::cout << "Dayrate: " << dayrate << "\n";
+ std::cout << "Hourly rate: " << hourly_rate << "\n";
double total_sum = 0;
for(int ii=0; ii < number_of_days; ii++) {
workday& each_day = workdays[ii];
double day_price = 0;
- std::cout << "\n ----- Day " << ii+1 << " ----- " << "\n";
+ std::cout << "\n ----- Day " << ii+1 << ": " << timeprint(each_day.call, false) << " ----- " << "\n";
for(int jj=0; jj < each_day.total_timeblocks; jj++) {
timeblock& each_block = each_day.blocks[jj];
double block_price = each_block.hourcount() * hourly_rate * each_block.valuefactor;
- std::cout << "Price of block " << jj << ": " << block_price << "\n";
+ std::cout << timeprint(each_block, true) << ", " << each_block.hourcount() << "h\t+" << (each_block.valuefactor-1)*100 << "%\t= " << block_price << "\n";
day_price += block_price;
}
- std::cout << "Price of day " << ii+1 << ": " << day_price << "\n";
+ std::cout << "Price of day " << ii+1 << ": " << day_price << std::endl;
total_sum += day_price;
}
diff --git a/src/time.cpp b/src/time.cpp
index 8507f0f..85dc78a 100755
--- a/src/time.cpp
+++ b/src/time.cpp
@@ -177,10 +177,13 @@ workday::workday(const moment& previous_wrap,
// THE VALUE-FACTOR CALCULATION PART
- // TODO: Implement a good system for this fuckin' paragraph:
- // A. 50 % tillegg for arbeid inntil 2 timer før, eller inntil 3 timer etter ordinær arbeidstid når arbeidstiden ikke er forskjøvet og overtiden er varslet. Dersom det varsles overtid både før og etter ordinær arbeidstid betales de to første timene med 50 % tillegg og de øvrige med 100 % tillegg.
// TODO: Complete the valuefactor calculation ruleset
// Including, Easter and other holidays
+ // TODO: Implement a good system for this fuckin' paragraph:
+ // A. 50 % tillegg for arbeid inntil 2 timer før, eller inntil 3 timer etter ordinær arbeidstid når arbeidstiden ikke er forskjøvet og overtiden er varslet. Dersom det varsles overtid både før og etter ordinær arbeidstid betales de to første timene med 50 % tillegg og de øvrige med 100 % tillegg.
+ // TODO: And this paragraph, which seems to say that planned being beyond actual wrap is a relevant case
+ // Varslet overtid som ikke benyttes honoreres med inntil to timer etter de vanlige overtidssatser, dog slik at én time av den ubenyttede overtiden ikke honoreres .
+ // TODO: Add reasons for the upped valuefactors.
for(int ii=0; ii < total_timeblocks; ii++){
timeblock& each_block = blocks[ii];
@@ -287,7 +290,7 @@ timeblock timesplit(timeblock& input_block, const moment splitpoint) {
// Splits a timeblock at splitpoint.
// It changes the input_block to start at splitpoint, and returns a new timeblock
// that lasts from where the input_block used to start, to splitpoint.
- // FIXME: timesplit will reset valuefactor of the first half
+ // BASICALLY: input_block becomes first half, output is second half.
if(splitpoint <= input_block.start || splitpoint >= input_block.end) {
std::cerr << "ERROR: Splitpoint outside of timeblock!\n";
std::cerr << "Timeblock: " << timeprint(input_block) << std::endl;
@@ -361,11 +364,30 @@ std::string timeprint(moment input_moment) {
+ padint(input_moment.day, 2);
return output;
}
+std::string timeprint(moment input_moment, bool clockonly) {
+ using namespace std;
+ string output;
+ if(clockonly) {
+ output =
+ padint(input_moment.hours, 2) + ":"
+ + padint(input_moment.minutes, 2);
+ } else {
+ output =
+ to_string(input_moment.year) + "-"
+ + padint(input_moment.month, 2) + "-"
+ + padint(input_moment.day, 2);
+ }
+ return output;
+}
std::string timeprint(timeblock input_timeblock) {
std::string output{timeprint(input_timeblock.start) + " --> " + timeprint(input_timeblock.end)};
return output;
}
+std::string timeprint(timeblock input_timeblock, bool clockonly) {
+ std::string output{timeprint(input_timeblock.start, clockonly) + " --> " + timeprint(input_timeblock.end, clockonly)};
+ return output;
+}
int days_in(int month, int year) {
diff --git a/src/time.h b/src/time.h
index 66c9e8c..6511213 100755
--- a/src/time.h
+++ b/src/time.h
@@ -95,7 +95,9 @@ void wind(moment& input_moment, const delta& time_delta);
int days_in(const int month, const int year);
std::string timeprint(const moment input_moment);
+std::string timeprint(const moment input_moment, bool clockonly);
std::string timeprint(const timeblock input_timeblock);
+std::string timeprint(const timeblock input_timeblock, bool clockonly);
long sortable_time(const timeblock input_timeblock);
moment timeinput(moment input_moment);