mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 22:47:20 +02:00
Made easter algorithm static in Date
This commit is contained in:
parent
10450963cb
commit
d3628c04db
3 changed files with 35 additions and 35 deletions
52
src/Date.cpp
52
src/Date.cpp
|
@ -643,6 +643,32 @@ int Date::monthOfYear (const std::string& input)
|
|||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
time_t Date::easter (int year)
|
||||
{
|
||||
int Y = year;
|
||||
int a = Y % 19;
|
||||
int b = Y / 100;
|
||||
int c = Y % 100;
|
||||
int d = b / 4;
|
||||
int e = b % 4;
|
||||
int f = (b + 8) / 25;
|
||||
int g = (b - f + 1) / 3;
|
||||
int h = (19 * a + b - d - g + 15) % 30;
|
||||
int i = c / 4;
|
||||
int k = c % 4;
|
||||
int L = (32 + 2 * e + 2 * i - h - k) % 7;
|
||||
int m = (a + 11 * h + 22 * L) / 451;
|
||||
int month = (h + L - 7 * m + 114) / 31;
|
||||
int day = ((h + L - 7 * m + 114) % 31) + 1;
|
||||
struct tm t = {0};
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
return mktime (&t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::month () const
|
||||
{
|
||||
|
@ -964,29 +990,3 @@ bool Date::isRelativeDate (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
time_t easter (int year)
|
||||
{
|
||||
int Y = year;
|
||||
int a = Y % 19;
|
||||
int b = Y / 100;
|
||||
int c = Y % 100;
|
||||
int d = b / 4;
|
||||
int e = b % 4;
|
||||
int f = (b + 8) / 25;
|
||||
int g = (b - f + 1) / 3;
|
||||
int h = (19 * a + b - d - g + 15) % 30;
|
||||
int i = c / 4;
|
||||
int k = c % 4;
|
||||
int L = (32 + 2 * e + 2 * i - h - k) % 7;
|
||||
int m = (a + 11 * h + 22 * L) / 451;
|
||||
int month = (h + L - 7 * m + 114) / 31;
|
||||
int day = ((h + L - 7 * m + 114) % 31) + 1;
|
||||
struct tm t = {0};
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
return mktime (&t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue