Automatic computation of easter and related holidays for the calendar

This commit is contained in:
Federico Hernandez 2010-05-11 00:01:17 +02:00
parent 68ae9173ae
commit 8553811889
3 changed files with 83 additions and 5 deletions

View file

@ -2,16 +2,20 @@
------ current release ---------------------------
1.9.1 ()
+ Fixed bug #382 in which the annotate command didn't return an error
message when called without an ID.
+ Summary report bar colors can now be specified with color.summary.bar
and color.summary.background configuration variables.
+ The configure script is more portable (thanks to Emil Sköldberg).
+ Updated task-faq.5 man page.
+ The 'edit' command now conveniently fills in the current date for new
annotations.
+ Deleting a task no longer clobbers any recorded end date (thanks to
Seneca Cunningham).
+ Following holidays are now computed automatically:
Good Friday (goodfriday), Easter (easter), Easter monday (eastermonday),
Ascension (ascension), Pentecost (pentecost)
The date is configured with the given keyword.
+ The configure script is more portable (thanks to Emil Sköldberg).
+ Updated task-faq.5 man page.
+ Fixed bug #382 in which the annotate command didn't return an error
message when called without an ID.
+ Fixed bug #402 which failed compilation on Arch Linux (thanks to
Johannes Schlatow).

View file

@ -414,6 +414,19 @@ Dates are to be entered according to the setting in the dateformat.holiday
variable.
.RE
.RS
The following holidays are computed automatically: Good Friday (goodfriday), Easter (easter), Easter monday (eastermonday), Ascension (ascension), Pentecost (pentecost). The date for these holidays is the given keyword:
.RE
.RS
.RS
.br
holiday.eastersunday.name=Easter
.br
holiday.eastersunday.date=easter
.RE
.RE
.TP
.B monthsperline=3
Determines how many months the "task calendar" command renders across the

View file

@ -792,7 +792,7 @@ bool Date::sameYear (const Date& rhs)
////////////////////////////////////////////////////////////////////////////////
Date Date::operator+ (const int delta)
{
return Date (mT + delta);
return Date::Date (mT + delta);
}
////////////////////////////////////////////////////////////////////////////////
@ -862,6 +862,13 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("eow");
supported.push_back ("eom");
supported.push_back ("eoy");
supported.push_back ("goodfriday");
supported.push_back ("easter");
supported.push_back ("eastermonday");
supported.push_back ("ascension");
supported.push_back ("pentecost");
supported.push_back ("midsommar");
supported.push_back ("midsommarafton");
std::vector <std::string> matches;
if (autoComplete (in, supported, matches) == 1)
@ -926,6 +933,60 @@ bool Date::isRelativeDate (const std::string& input)
mT = then.mT;
return true;
}
else if (found == "goodfriday")
{
Date then (Date::easter(today.year()));
mT = then.mT - 86400*2;
return true;
}
else if (found == "easter")
{
Date then (Date::easter(today.year()));
mT = then.mT;
return true;
}
else if (found == "eastermonday")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400;
return true;
}
else if (found == "ascension")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400*39;
return true;
}
else if (found == "pentecost")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400*49;
return true;
}
else if (found == "midsommar")
{
for (int midsommar = 20; midsommar <= 26; midsommar++)
{
Date then (6, midsommar, today.year ());
if (6 == then.dayOfWeek ())
{
mT = then.mT;
return true;
}
}
}
else if (found == "midsommarafton")
{
for (int midsommar = 19; midsommar <= 25; midsommar++)
{
Date then (6, midsommar, today.year ());
if (5 == then.dayOfWeek ())
{
mT = then.mT;
return true;
}
}
}
}
// Support "21st" to indicate the next date that is the 21st day.