Feature #446 - start of {week, month, year}

- Added sow (depending on rc.weekstart), som and soy as possible
  dates (similar to eow, eom and eoy).
This commit is contained in:
Federico Hernandez 2010-07-28 00:15:26 +02:00
parent a6fbb40a12
commit 96bd3ff8db
5 changed files with 51 additions and 8 deletions

View file

@ -887,6 +887,9 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("eow");
supported.push_back ("eom");
supported.push_back ("eoy");
supported.push_back ("sow");
supported.push_back ("som");
supported.push_back ("soy");
supported.push_back ("goodfriday");
supported.push_back ("easter");
supported.push_back ("eastermonday");
@ -903,11 +906,16 @@ bool Date::isRelativeDate (const std::string& input)
// If day name.
int dow;
if ((dow = Date::dayOfWeek (found)) != -1 ||
found == "eow")
found == "eow" ||
found == "eocw" ||
found == "sow")
{
if (found == "eow")
dow = 5;
if (found == "sow")
dow =Date::dayOfWeek (context.config.get ("weekstart"));
if (today.dayOfWeek () >= dow)
today += (dow - today.dayOfWeek () + 7) * 86400;
else
@ -958,6 +966,20 @@ bool Date::isRelativeDate (const std::string& input)
mT = then.mT;
return true;
}
else if (found == "som")
{
Date then (today.month (),
1,
today.year ());
mT = then.mT;
return true;
}
else if (found == "soy")
{
Date then (1, 1, today.year ());
mT = then.mT;
return true;
}
else if (found == "goodfriday")
{
Date then (Date::easter(today.year()));