From b519bd534360d265d30366dc8b5ea7ffb2741b41 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 5 Jun 2007 15:28:08 +0000 Subject: [PATCH] Patch level : 4.0 Files correlati : mr Ricompilazione Demo : [ ] Commento : Corretto calcolo della Pasqua (serve solo al calendario MRP) git-svn-id: svn://10.65.10.50/trunk@15397 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/date.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/include/date.cpp b/include/date.cpp index 0e97e468c..21d27695e 100755 --- a/include/date.cpp +++ b/include/date.cpp @@ -377,27 +377,26 @@ int TDate::week() const return int((*this - y) / 7 + 1); } +// Calcola la Pasqua per gli anni compresi tra 1900 e 2200 void TDate::set_easter(int n) { - if (n > 0) - set_year(n); + const int y = n > 0 ? n : year(); + const int correction = y < 2100 ? 0 : 1; // Semplificazione tabella dal 1600 al 2500 + int d = (19 * (y%19) + 24) % 30; + d += 22 + ((2*(y%4) + 4*(y%7) + 6*d + 5 + correction) % 7); - const int y = year(); - const int g = y % 19; - const int c = y / 200; - const int h = (c - c / 4 - (8 * c + 13) / 25 + 19 * g+ 15) % 30; - const int i = h - (h / 28) * (1 - (29 / (h + 1)) * ((21 - g) / 11)); - const int j = (y + y / 4 + i + 2 - c + c / 4) % 7; - const int l = i - j; - const int m = 3 + (l + 40) / 44; - set_month(m); - const int d = l + 28 - 31 * (m / 4); - set_day(d); + int m = 3; + if (d > 31) + { + d -= 31; + m++; + } + _val = makedata(d, m, y); } bool TDate::is_holiday() const { - if (wday() > 5) // Week-end + if (wday() == 7) // Domenica return true; const int d = day(); const int m = month();