- Added Feature #1039, which adds new date shortcuts, 'socm' and 'eocm',
  meaning start and end of current month (thanks to Thomas Sullivan,
  Louis-Claude Canon).
This commit is contained in:
Paul Beckingham 2012-12-01 14:22:09 -05:00
parent 12b12c3a62
commit 4e03832b68
5 changed files with 54 additions and 36 deletions

View file

@ -56,12 +56,14 @@ static const char* relatives[] =
"eow",
"eoww",
"eocw",
"eocm",
"eom",
"eoq",
"eoy",
"sow",
"soww",
"socw",
"socm",
"som",
"soq",
"soy",
@ -828,7 +830,8 @@ bool Date::isRelativeDate (const std::string& input)
found == "eocw" ||
found == "sow" ||
found == "soww" ||
found == "socw")
found == "socw" ||
found == "socm")
{
if (found == "eow" || found == "eoww")
dow = 5;
@ -847,6 +850,9 @@ bool Date::isRelativeDate (const std::string& input)
else
today += (dow - today.dayOfWeek ()) * 86400;
if (found == "socm")
today -= (today.day () - 1) * 86400;
int m, d, y;
today.toMDY (m, d, y);
Date then (m, d, y);
@ -878,7 +884,7 @@ bool Date::isRelativeDate (const std::string& input)
_t = then._t - 86400;
return true;
}
else if (found == "eom")
else if (found == "eom" || found == "eocm")
{
Date then (today.month (),
daysInMonth (today.month (), today.year ()),