mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
helper: Added new quantizeToNMinutes function
This commit is contained in:
parent
52c294cc4c
commit
44f19d0c01
2 changed files with 14 additions and 0 deletions
|
@ -296,6 +296,19 @@ int quantizeTo15Minutes (const int minutes)
|
|||
return minutes + 15 - deviation;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int quantizeToNMinutes (const int minutes, const int N)
|
||||
{
|
||||
if (minutes % N == 0)
|
||||
return minutes;
|
||||
|
||||
auto deviation = minutes % N;
|
||||
if (deviation < N/2)
|
||||
return minutes - deviation;
|
||||
|
||||
return minutes + N - deviation;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Check rules to see if day is a holiday.
|
||||
bool dayIsHoliday (const Rules& rules, const Datetime& day)
|
||||
|
|
|
@ -70,6 +70,7 @@ std::string jsonFromIntervals (const std::vector <Interval>&);
|
|||
Palette createPalette (const Rules&);
|
||||
std::map <std::string, Color> createTagColorMap (const Rules&, Palette&, const std::vector <Interval>&);
|
||||
int quantizeTo15Minutes (const int);
|
||||
int quantizeToNMinutes (const int, const int);
|
||||
bool dayIsHoliday (const Rules&, const Datetime&);
|
||||
bool findHint (const CLI&, const std::string&);
|
||||
std::string minimalDelta (const Datetime&, const Datetime&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue