helper: Changed ::expandIntervalHint to operate on a range

This commit is contained in:
Paul Beckingham 2016-05-28 14:34:18 -04:00
parent 98899acc4d
commit 13d73a0e6d
3 changed files with 8 additions and 8 deletions

View file

@ -62,7 +62,8 @@ Interval getFilter (const CLI& cli)
if (arg.hasTag ("HINT"))
{
if (expandIntervalHint (canonical, start, end))
Range dummy;
if (expandIntervalHint (canonical, dummy))
{
args.push_back ("<date>");
args.push_back ("-");

View file

@ -108,8 +108,7 @@ std::string intervalSummarize (
// Convert a set of hints to equivalent date ranges.
bool expandIntervalHint (
const std::string& hint,
std::string& start,
std::string& end)
Range& range)
{
static std::map <std::string, std::vector <std::string>> hints
{
@ -124,8 +123,8 @@ bool expandIntervalHint (
// Some hints are just synonyms.
if (hints.find (hint) != hints.end ())
{
start = hints[hint][0];
end = hints[hint][1];
range.start = Datetime (hints[hint][0]);
range.end = Datetime (hints[hint][1]);
return true;
}
@ -136,8 +135,8 @@ bool expandIntervalHint (
Datetime eocw ("eocw");
socw -= 7 * 86400;
eocw -= 7 * 86400;
start = socw.toString ("Y-M-D");
end = eocw.toString ("Y-M-D");
range.start = Datetime (socw.toString ("Y-M-D"));
range.end = Datetime (eocw.toString ("Y-M-D"));
}
return false;

View file

@ -65,7 +65,7 @@ int dispatchCommand (const CLI&, Database&, Rules&, const Extensions&);
// helper.cpp
Color tagColor (const Rules&, const std::string&);
std::string intervalSummarize (Database&, const Rules&, const Interval&);
bool expandIntervalHint (const std::string&, std::string&, std::string&);
bool expandIntervalHint (const std::string&, Range&);
std::string jsonFromIntervals (const std::vector <Interval>&);
Palette createPalette (const Rules&);
std::map <std::string, Color> createTagColorMap (const Rules&, Palette&, const std::vector <Interval>&);