From 871436abc5a0a27bc9e70204edf19b27bfefab45 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Sun, 15 Oct 2023 15:09:08 +0200 Subject: Removed some old stuff --- src/main.odin | 2 - src/test.cpp | 96 ---------- src/test.h | 6 - src/time.cpp | 574 ---------------------------------------------------------- src/time.h | 112 ------------ 5 files changed, 790 deletions(-) delete mode 100644 src/test.cpp delete mode 100644 src/test.h delete mode 100755 src/time.cpp delete mode 100755 src/time.h diff --git a/src/main.odin b/src/main.odin index 698f044..5e2ddc2 100644 --- a/src/main.odin +++ b/src/main.odin @@ -47,8 +47,6 @@ main :: proc() { } - //if true do return - /*workday0: = new_workday({10, 22, 3, 5, 2023}, {00, 08, 4, 5, 2023}, {00, 22, 4, 5, 2023}, diff --git a/src/test.cpp b/src/test.cpp deleted file mode 100644 index 0b97b4a..0000000 --- a/src/test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "test.h" -#include "time.h" - -void test(){ - moment calltime{30, 8, 27, 11, 2010}; - moment wraptime{30, 16, 27, 11, 2010}; - timeblock workday{calltime, wraptime}; - - std::cout << "\n\n --- TIME UNITS TEST ---\n\n"; - std::cout << "Calltime: " << timeprint(calltime) << std::endl; - std::cout << "Wraptime: " << timeprint(wraptime) << std::endl; - - std::cout << "\nWorkday:\n"; - std::cout << timeprint(workday) << std::endl; - - - - std::cout << "\n\n --- TIME MATH TEST ---\n\n"; - - std::cout << "Difference between calltime and wraptime:\n"; - std::cout << (calltime-wraptime) << std::endl; - std::cout << "Other way around, should show same result:\n"; - std::cout << (calltime-wraptime) << std::endl; - std::cout << "As method on workday:\n"; - std::cout << (workday.hourcount()) << std::endl; - - std::cout << "\nSplitting workday into workday and second_half...\n"; - moment splitpoint{0, 12, 27, 11, 2010}; - timeblock first_half{timesplit(workday, splitpoint)}; - - std::cout << "\nSplitpoint: " << timeprint(splitpoint) << std::endl; - std::cout << "\nfirst_half:\n"; - std::cout << timeprint(first_half) << std::endl; - std::cout << "\nWorkday:\n"; - std::cout << timeprint(workday) << std::endl; - - std::cout << "\nSplitting second_half at erronious point...\n"; - moment erronious_splitpoint{0, 14, 27, 11, 2010}; - std::cout << timeprint(timesplit(first_half, erronious_splitpoint)) << "\n"; - - - - std::cout << "\n\n --- TIME WINDING TEST ---\n\n"; - - moment testtime{30, 8, 25, 2, 2012}; - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - - std::cout << "\nForwarding 45 minutes...\n"; - wind(testtime, 45, 0, 0); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - std::cout << "\nRewinding 45 minutes...\n"; - wind(testtime, -45, 0, 0); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - - std::cout << "\nForwarding 20 hours...\n"; - wind(testtime, 0, 20, 0); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - std::cout << "\nRewinding 20 hours...\n"; - wind(testtime, 0, -20, 0); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - - std::cout << "\nForwarding 10 days...\n"; - wind(testtime, 0, 0, 10); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - std::cout << "\nRewinding 10 days...\n"; - wind(testtime, 0, 0, -10); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - - std::cout << "\nForwarding 100 days...\n"; - wind(testtime, 0, 0, 100); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - std::cout << "\nRewinding 100 days...\n"; - wind(testtime, 0, 0, -100); - std::cout << "Testtime: " << timeprint(testtime) << std::endl; - - - std::cout << "\n\n --- HOLIDAY TEST ---\n\n"; - std::cout << "Easter 2022: " << timeprint(gaussEaster(2022)) << std::endl; - std::cout << "Easter 2030: " << timeprint(gaussEaster(2030)) << std::endl; - std::cout << "Easter 2057: " << timeprint(gaussEaster(2057)) << std::endl; - - std::cout << "\n\n --- TIME INPUT TEST ---\n\n"; - - moment inputmoment = timeinput(); - std::cout << "Time reveived: " << timeprint(inputmoment) << std::endl; - moment inputmoment2 = timeinput(inputmoment); - std::cout << "Time reveived: " << timeprint(inputmoment2) << std::endl; -} diff --git a/src/test.h b/src/test.h deleted file mode 100644 index bf54737..0000000 --- a/src/test.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include -#include -#include - -void test(); diff --git a/src/time.cpp b/src/time.cpp deleted file mode 100755 index 0aa7bd0..0000000 --- a/src/time.cpp +++ /dev/null @@ -1,574 +0,0 @@ -#include "time.h" - -// Look. listen here. There's no way I'm going to start taking DST into account. -// DST transition times are decided using skull dice, by the grand wizards of the state. -// The fact that DST is designed this way, though, -// makes it so you are unlikely to be on the clock during a DST transition. - - -// -// --- OPERATOR OVERLOADS --- -// - -long long sortable_time(const moment input_moment) { - return stoll(std::to_string(input_moment.year)+ - padint(input_moment.month,2)+ - padint(input_moment.day,2)+ - padint(input_moment.hours,2)+ - padint(input_moment.minutes,2)); -} - -bool moment::operator<(const moment& other) const{ - return bool(sortable_time(*this) < sortable_time(other)); -} - -bool moment::operator>(const moment& other) const{ - return bool(sortable_time(*this) > sortable_time(other)); -} - -bool moment::operator==(const moment& other) const { - return bool(year==other.year && - month==other.month && - day==other.day && - hours==other.hours && - minutes==other.minutes); -} - -bool moment::operator<=(const moment& other) const { - return bool((*this < other) || *this == other); -} - -bool moment::operator>=(const moment& other) const { - return bool((*this > other) || *this == other); -} - -bool moment::operator!=(const moment& other) const { - return bool(year!=other.year || - month!=other.month || - day!=other.day || - hours!=other.hours || - minutes!=other.minutes); -} -moment moment::operator+(const delta& other) const { - moment output{*this}; - wind(output, other.minutes, other.hours, other.days); - return output; -} -moment moment::operator-(const delta& other) const { - moment output{*this}; - wind(output, other.minutes*-1, other.hours*-1, other.days*-1); - return output; -} - -delta moment::operator-(const moment& other) const { - // Uses what I call an accumulator-decumulator design - // Count how long it takes to approach a benchmark, - // and that count is the difference - - if(*this==other) return{0,0,0}; - delta accumulator{0,0,0}; - - // smallest operand becomes benchmark to approach - const bool reverse{*this 1 || - decumulator.month - benchmark.month > 1 || - decumulator.day - benchmark.day > 1) { - wind(decumulator, 0, 0, -1); - accumulator.days++; - } - - while(decumulator.hours - benchmark.hours > 1) { - wind(decumulator, 0, -1, 0); - accumulator.hours++; - } - while(accumulator.hours > 23) { - accumulator.hours -= 24; - accumulator.days++; - } - - while(decumulator != benchmark) { - wind(decumulator, -1, 0, 0); - accumulator.minutes++; - } - while(accumulator.minutes > 59) { - accumulator.minutes -= 60; - accumulator.hours++; - } - - return accumulator; -} - -std::ostream& operator<<(std::ostream& stream, const delta& other) { - if(other.days==0 && other.hours==0 && other.minutes==0){ - stream << "None."; - return stream; - } - if(other.days) stream << other.days << " days, "; - if(other.hours) stream << other.hours << " hours, "; - if(other.minutes) stream << other.minutes << " minutes."; - return stream; -} - - -// -// --- CONSTRUCTORS --- -// - -workday::workday(const moment& previous_wrap, - const moment& calltime, - const moment& wraptime, - const moment& planned_wraptime) { - call = calltime; - wrap = wraptime; - planned_wrap = planned_wraptime; - 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 = 11; - 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. - // Maybe this should be a struct? - // Or maybe I should just implement this badly at first just to get it working, and replace it later? - - previous_wrap+(delta){0, 10, 0}, // Sleepbreach, 10 hours after previous wrap 0x - (moment){0, 5, call.day, call.month, call.year}, // 2 hours before 7, aka 5 1x - (moment){0, 6, call.day, call.month, call.year}, // 6 in the morning 2x - call+(delta){0, 8, 0}, // Normal 8 hours of work 3x - call+(delta){0, 9, 0}, // 1st hour of overtime is over 4x - call+(delta){0, 11, 0}, // 3st hour of overtime is over 5x - planned_wraptime, // End of warned overtime 6x - call+(delta){0, 14, 0}, // The 14-hour mark 7x - (moment){0, 22, call.day, call.month, call.year}, // 22:00 in the evening 8x - (moment){0, 23, call.day, call.month, call.year}+(delta){0, 1, 0}, // Midnight 9x - (moment){0, 23, call.day, call.month, call.year}+(delta){0, 7, 0}, // 6, next morning 10x - }; - - // Eliminate planned wrap, if it occurs within normal 8-hour period. - // This is to make sure the first period of time becomes a pure 8 hours, - // which makes detecting the main section of the workday easier. - if(splitpoints[6] < splitpoints[3]){ - splitpoints[6] = splitpoints[3]; - } - - 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 call && *each_moment < wrap && *each_moment != initial_block.start) { - blocks[j++] = timesplit(initial_block, *each_moment); - } - } - - blocks[j++] = initial_block; - total_timeblocks = j; - - // THE VALUE-FACTOR CALCULATION PART - - // TODO: Consider replacing splitpoints[x] with redoing the math for code flexibility? - - for(int ii=0; ii < total_timeblocks; ii++){ - timeblock& each_block = blocks[ii]; - //std::cout << "pricing: " << timeprint(each_block) << std::endl; - - if(each_block.end <= splitpoints[0]) each_block.upvalue(3, "Sleep-breach"); // +200% for sleep-breach - if(each_block.start.hours >= 22) each_block.upvalue(2, "Night"); // Work between 22:00 - if((each_block.end.hours == 6 && each_block.end.minutes == 0) ||// And 06:00 - (each_block.end.hours <= 5)) each_block.upvalue(2, "Night"); // is +100% - if(each_block.start >= splitpoints[3]) {each_block.upvalue(1.5, "Overtime"); // Overtime - if(each_block.start.getweekday() == saturday) each_block.upvalue(2, "Saturday overtime");// on saturdays - } - if(each_block.start >= splitpoints[5]) each_block.upvalue(2, "Overtime"); // End of 3-hour cheap planned overtime - if(each_block.start >= planned_wraptime && // Unwarned overtime - each_block.start >= splitpoints[4]) each_block.upvalue(2, "Overtime"); // +100% after first hour - if(each_block.start >= splitpoints[7]) each_block.upvalue(3, "Far overtime"); // +200% beyond 14-hour mark - if(each_block.start.getweekday() == saturday) each_block.upvalue(1.5, "Saturday");// Saturdays are +50% - if(each_block.start.getweekday() == sunday) each_block.upvalue(2, "Sunday"); // Sundays are +100% - - if(!(call < (moment){0, 7, call.day, call.month, call.year} && // On an offset day... - std::min(call+(delta){0,8,0}, wrap) < (moment){0,17,call.day,call.month,call.year})) { - // This was added for rule 6.11c, but in a world without a defined normal workday, - // that rule is already covered already by 6.11g, so this is empty. - } - - // Holidays! - if(each_block.start.day==1 && each_block.start.month==1) each_block.upvalue(2, "New year"); - if(each_block.start.day==1 && each_block.start.month==5) each_block.upvalue(2, "1st of May"); - if(each_block.start.day==17 && each_block.start.month==5) each_block.upvalue(2, "17st of May"); - if((each_block.start.day==25 || each_block.start.day==26) && each_block.start.month==12) - each_block.upvalue(2, "Christmas"); - moment easter = gaussEaster(each_block.start.year); - if(each_block.start.day == (easter-(delta){0,0,3}).day && - each_block.start.month == (easter-(delta){0,0,3}).month) each_block.upvalue(2, "Maundy Thursday"); - if(each_block.start.day == (easter-(delta){0,0,2}).day && - each_block.start.month == (easter-(delta){0,0,2}).month) each_block.upvalue(2, "Good Friday"); - if(each_block.start.day == easter.day && each_block.start.month == easter.month) each_block.upvalue(2, "Easter"); - if(each_block.start.day == (easter+(delta){0,0,1}).day && - each_block.start.month == (easter+(delta){0,0,1}).month) each_block.upvalue(2, "Easter"); - if(each_block.start.day == (easter+(delta){0,0,39}).day && - each_block.start.month == (easter+(delta){0,0,39}).month) each_block.upvalue(2, "Feast of the Ascension"); - if(each_block.start.day == (easter+(delta){0,0,49}).day && - each_block.start.month == (easter+(delta){0,0,49}).month) each_block.upvalue(2, "Pentecost"); - if(each_block.start.day == (easter+(delta){0,0,50}).day && - each_block.start.month == (easter+(delta){0,0,50}).month) each_block.upvalue(2, "Pentecost Monday"); - } - -} - -void workday::lunch(const moment& lunch_start, const moment& lunch_end) { - if(lunch_start > lunch_end){ - std::cout << "ERROR: Lunch ends before it began." << std::endl; - } - for(int ii=0; ii < total_timeblocks; ii++){ - timeblock& each_block = blocks[ii]; - timeblock& next_block = blocks[ii+1]; // FIXME: On final loop, next_block will be garbage data - - if(each_block.start < lunch_start && each_block.end > lunch_end){ - // If lunch simply occurs within a timeblock - // Split out the section, discarding the middle - timeblock first_half = timesplit(each_block, lunch_start); - each_block.start = lunch_end; - // Move all points after lunch out by 1 - for(int x=total_timeblocks; x>=ii; x--) { - blocks[x+1] = blocks[x]; - } - total_timeblocks++; - // Re-insert second half of split section into ii+1 - blocks[ii] = first_half; - return; - - } else if(ii!=total_timeblocks-1 && each_block.start < lunch_start && lunch_start < each_block.end && - next_block.start < lunch_end && lunch_end < next_block.end) { - // If we're not on the final block AND - // If lunch occurs between two timeblocks - each_block.end = lunch_start; - next_block.start = lunch_end; - return; - - } else if(each_block.start == lunch_start) { - // If lunch starts at the beginning of a timeblock - each_block.start = lunch_end; - return; - - } else if(each_block.end == lunch_end) { - // If lunch ends at the end of a timeblock - each_block.start = lunch_end; - return; - } - // FIXME: If lunch spans across more than 1 border between timeblocks, bad stuff will happen. - // Maybe there is a more principled way of solving this, that doesn't require writing code - // for a bunch of edge-cases. If not, write the code. - } - return; -} - - -// -// --- METHODS --- -// - -double timeblock::hourcount() { - delta timedelta = end-start; - return (timedelta.minutes/60.0f + - timedelta.hours + - timedelta.days*24); -} - -float timeblock::upvalue(float suggestion, std::string reason){ - if(suggestion>valuefactor) { - valuefactor = suggestion; - price_reason = reason; - } - return valuefactor; -} - -weekday moment::getweekday() { - // Based on implementation from NProg on StackOverflow. Thanks. - int y = year; - static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; - y -= month < 3; - return static_cast((y + y / 4 - y / 100 + y / 400 + t[month - 1] + day - 1) % 7); -} - -bool moment::isEaster() { - moment easter = gaussEaster(year); - return (easter.month==month && easter.day==day); -} - - -// -// --- FUNCTIONS --- -// - -moment gaussEaster(int year) { - // Thanks to Carl Friedrich Gauss for the algorythm - // Thanks rahulhegde97, bansal_rtk_, code_hunt, sanjoy_62, simranarora5sos - // and aashutoshparoha on GeeksForGeeks for the implementation I based this on. - float A, B, C, P, Q, M, N, D, E; - int easter_month = 0; - int easter_day = 0; - - // All calculations done - // on the basis of - // Gauss Easter Algorithm - A = year % 19; - B = year % 4; - C = year % 7; - P = std::floor((float)year / 100.0); - - Q = std::floor((float)(13 + 8 * P) / 25.0); - - M = (int)(15 - Q + P - (std::floor)(P / 4)) % 30; - - N = (int)(4 + P - (std::floor)(P / 4)) % 7; - - D = (int)(19 * A + M) % 30; - - E = (int)(2 * B + 4 * C + 6 * D + N) % 7; - - int days = (int)(22 + D + E); - easter_day = days; - - // A corner case, - // when D is 29 - if ((D == 29) && (E == 6)) { - easter_month = 4; - easter_day = 19; - } - // Another corner case, - // when D is 28 - else if ((D == 28) && (E == 6)) { - easter_month = 4; - easter_day = 18; - } - else { - // If days > 31, move to April - // April = 4th Month - if (days > 31) { - easter_month = 04; - easter_day = days-31; - } - else { - // Otherwise, stay on March - // March = 3rd Month - easter_month = 03; - } - } - return (moment){0,0, easter_day, easter_month, year}; -} - -std::string padint(const int input, const int minimum_signs) { - std::ostringstream output; - output << std::internal << std::setfill('0') << std::setw(minimum_signs) << input; - return output.str(); -} - -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. - // 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; - std::cerr << "Splitpoint: " << timeprint(splitpoint) << std::endl; - } - timeblock output{input_block.start, splitpoint}; - output.valuefactor = input_block.valuefactor; - output.price_reason = input_block.price_reason; - input_block.start = splitpoint; // Note: Now, reversed. - return output; -} - -void wind(moment& input_moment, const int minutes, const int hours, const int days) { - - // Adding minutes - input_moment.minutes += minutes; - while(input_moment.minutes > 59) { - input_moment.minutes -= 60; - input_moment.hours++; - } - while(input_moment.minutes < 0) { - input_moment.minutes += 60; - input_moment.hours--; - } - - // Adding hours - input_moment.hours += hours; - while(input_moment.hours > 23) { - input_moment.hours -= 24; - input_moment.day++; - } - while(input_moment.hours < 0) { - input_moment.hours += 24; - input_moment.day--; - } - - // Adding days - input_moment.day += days; - int current_month_length = days_in(input_moment.month, input_moment.year); - while(input_moment.day > current_month_length) { - input_moment.day -= current_month_length; - input_moment.month++; - if(input_moment.month > 12) { - input_moment.month -= 12; - input_moment.year++; - } - current_month_length = days_in(input_moment.month, input_moment.year); - } - while(input_moment.day < 1) { - input_moment.month--; - if(input_moment.month < 1) { - input_moment.month += 12; - input_moment.year--; - } - current_month_length = days_in(input_moment.month, input_moment.year); - input_moment.day += current_month_length; - } -} -void wind(moment& input_moment, const delta& time_delta) { - wind(input_moment, time_delta.minutes, time_delta.hours, time_delta.days); -} - -std::string timeprint(moment input_moment) { - using namespace std; - string output = - padint(input_moment.hours, 2) + ":" - + padint(input_moment.minutes, 2) + " " - + to_string(input_moment.year) + "-" - + padint(input_moment.month, 2) + "-" - + 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) { - // Kind of a stupid and slow way to do this - // But it's nice to have it as a function - // because of the leap year arithmatic - switch (month) { - case 1: - return 31; - case 2: - if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)){ - return 29; - } - return 28; - case 3: - return 31; - case 4: - return 30; - case 5: - return 31; - case 6: - return 30; - case 7: - return 31; - case 8: - return 31; - case 9: - return 30; - case 10: - return 31; - case 11: - return 30; - case 12: - return 31; - } - std::cout << "Something just went very wrong. You found month #" << std::to_string(month) << '\n'; - return 5; -} - -// TODO: Add checks for correct formatting, and ask for new input if wrong -moment timeinput(moment input_moment) { - char input_string[6]; - std::cout << "HH MM (24-hour format, use space)" << std::endl; - std::cin.getline(input_string, 6); - - // This uglyness is just how you use strtok() to split a string, apparently - const char* p; - int split_input[2]; - int i{0}; - p = strtok(input_string, " "); - while (p != NULL) { - split_input[i] = int(atoi(p)); - i++; - p = strtok(NULL, " "); - } - - if((moment){split_input[1], split_input[0], - input_moment.day, input_moment.month, input_moment.year} < input_moment) - { - wind(input_moment, 0, 0, 1); - } - - moment output{split_input[1], split_input[0], - input_moment.day, input_moment.month, input_moment.year}; - return output; -} - -moment timeinput() { - char input_string[17]; - 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 - const char* p; - int split_input[5]; - int i{0}; - p = strtok(input_string, " "); - while (p != NULL) { - split_input[i] = int(atoi(p)); - i++; - p = strtok(NULL, " "); - } - - moment output{split_input[4], - split_input[3], - split_input[2], - split_input[1], - split_input[0]}; - return output; -} diff --git a/src/time.h b/src/time.h deleted file mode 100755 index 52562bd..0000000 --- a/src/time.h +++ /dev/null @@ -1,112 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -enum weekday{ - monday, - tuesday, - wednesday, - thursday, - friday, - saturday, - sunday -}; - -struct delta{ - unsigned int minutes; - unsigned int hours; - unsigned int days; -}; -std::ostream& operator<<(std::ostream& stream, const delta& other); - -struct moment{ - signed int minutes; - signed int hours; // 24-hour format. 23:59 progresses to 00:00 - signed int day; - signed int month; - signed int year; - - weekday getweekday(); - bool isEaster(); - - bool operator<(const moment& other) const; - bool operator>(const moment& other) const; - bool operator<=(const moment& other) const; - bool operator>=(const moment& other) const; - bool operator==(const moment& other) const; - bool operator!=(const moment& other) const; - delta operator-(const moment& other) const; - moment operator+(const delta& other) const; - moment operator-(const delta& other) const; -}; - -struct timeblock{ - moment start; - moment end; - double hourcount(); - float valuefactor = 1; - float upvalue(float suggestion, std::string reason); - std::string price_reason = "Norm"; -}; - -struct workday{ - moment call; - moment wrap; - moment planned_wrap; - timeblock blocks[15]; - int total_timeblocks; - // total_timeblocks exsists because blocks can't be shrunk, - // so total_timeblocks is the point at which blocks - // just contains garbage data. - // - // 1. call - // 2. sleepbreach - // 3. 6:00 - // 4. started 2 hours before 7 - // 5. 1st hr overtime - // 6. post-1 hour overtime - // 7. end of warned ot - // 8. 14-hour mark - // 9. 22:00 - // 10. midnight crossing - // 11. 06:00 - // 12. wrap - // - workday(const moment& previous_wrap, - const moment& calltime, - const moment& wraptime, - const moment& planned_wraptime); - workday(){}; - void lunch(const moment& lunch_start, const moment& lunch_end); -}; - -std::string padint(const int input, const int minimum_signs); - -timeblock timesplit(timeblock& input_block, const moment splitpoint); - // Splits a timeblock at splitpoint. - // It changes the input_block to end at splitpoint, and returns a new timeblock - // that lasts from splitpoint to where the input_block used to end. - -void wind(moment& input_moment, const int minutes, const int hours, const int days); -void wind(moment& input_moment, const delta& time_delta); - -int days_in(const int month, const int year); - -moment gaussEaster(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 long sortable_time(const timeblock input_timeblock); - -moment timeinput(moment input_moment); -moment timeinput(); -// TODO: Completely re-write timeinput to be beautiful and enforce valid dates - -- cgit v1.2.1