helper: Added expandIntervalHint

This commit is contained in:
Paul Beckingham 2016-04-06 21:44:12 -04:00
parent 291eef994a
commit f36410cbad
2 changed files with 25 additions and 0 deletions

View file

@ -29,6 +29,8 @@
#include <Duration.h>
#include <sstream>
#include <iomanip>
#include <map>
#include <tuple>
////////////////////////////////////////////////////////////////////////////////
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]);
}
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -44,6 +44,7 @@ int dispatchCommand (CLI&, Database&, Rules&, Extensions&);
// helper.cpp
Color tagColor (const Rules&, const std::string&);
std::string intervalSummarize (const Rules&, const Interval&);
void expandIntervalHint (const std::string&, std::string&, std::string&);
// utiŀ.cpp
std::string osName ();