mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
helper: Added expandIntervalHint
This commit is contained in:
parent
291eef994a
commit
f36410cbad
2 changed files with 25 additions and 0 deletions
|
@ -29,6 +29,8 @@
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <map>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color tagColor (const Rules& rules, const std::string& tag)
|
Color tagColor (const Rules& rules, const std::string& tag)
|
||||||
|
@ -83,3 +85,25 @@ std::string intervalSummarize (const Rules& rules, const Interval& interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void expandIntervalHint (
|
||||||
|
const std::string& hint,
|
||||||
|
std::string& start,
|
||||||
|
std::string& end)
|
||||||
|
{
|
||||||
|
static std::map <std::string, std::tuple <std::string, std::string>> hints
|
||||||
|
{
|
||||||
|
{":week", {"socw", "eocw"}},
|
||||||
|
{":month", {"socw", "eocw"}},
|
||||||
|
{":quarter", {"socw", "eocw"}},
|
||||||
|
{":year", {"socw", "eocw"}},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (hints.find (hint) == hints.end ())
|
||||||
|
if (hints.find (hint) != hints.end ())
|
||||||
|
{
|
||||||
|
start = std::get <0> (hints[hint]);
|
||||||
|
end = std::get <1> (hints[hint]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -44,6 +44,7 @@ int dispatchCommand (CLI&, Database&, Rules&, Extensions&);
|
||||||
// helper.cpp
|
// helper.cpp
|
||||||
Color tagColor (const Rules&, const std::string&);
|
Color tagColor (const Rules&, const std::string&);
|
||||||
std::string intervalSummarize (const Rules&, const Interval&);
|
std::string intervalSummarize (const Rules&, const Interval&);
|
||||||
|
void expandIntervalHint (const std::string&, std::string&, std::string&);
|
||||||
|
|
||||||
// utiŀ.cpp
|
// utiŀ.cpp
|
||||||
std::string osName ();
|
std::string osName ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue