Patch level : 2.2 no patch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Aggiunta Pasqua e Lunedi' dell'Angelo alle date


git-svn-id: svn://10.65.10.50/trunk@13314 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2005-08-23 08:41:42 +00:00
parent 92151c5cd5
commit 758ff5de03
4 changed files with 60 additions and 33 deletions

@ -382,30 +382,56 @@ int TDate::week() const
return int((*this - y) / 7 + 1);
}
void TDate::set_easter(int n)
{
if (n > 0)
set_year(n);
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);
}
bool TDate::is_holiday() const
{
bool holiday = wday() > 5; // Week-end
if (!holiday)
if (wday() > 5) // Week-end
return true;
const int d = day();
const int m = month();
if ((m == 1) && ((d == 1) || (d == 6))) // Capodanno ed Epifania
return true;
if ((m == 4) && (d == 25)) // Liberazione
return true;
if ((m == 5) && (d == 1)) // Festa dei Lavoratori
return true;
if ((m == 6) && (d == 2)) // Festa della Repubblica
return true;
if ((m == 8) && (d == 15)) // Ferragosto
return true;
if ((m == 11) && (d == 1)) // Ognissanti
return true;
if ((m == 12) && ((d == 8) || (d == 25) || (d == 26)))
return true;
if (m == 3 || m == 4 && wday() == 1)
{
const int d = day();
const int m = month();
if ((m == 1) && ((d == 1) || (d == 6))) // Capodanno ed Epifania
return true;
if ((m == 4) && (d == 25)) // Liberazione
return true;
if ((m == 5) && (d == 1)) // Festa dei Lavoratori
return true;
if ((m == 6) && (d == 2)) // Festa della Repubblica
return true;
if ((m == 8) && (d == 15)) // Ferragosto
return true;
if ((m == 11) && (d == 1)) // Ognissanti
return true;
if ((m == 12) && ((d == 8) || (d == 25) || (d == 26)))
TDate angelo;
angelo.set_easter(year());
++angelo;
if (angelo == *this)
return true;
}
return holiday;
return false;
}
TDate& TDate::operator +=(long nday)

@ -122,6 +122,8 @@ public:
// @cmember Permette di stabilire il criterio di formattazione delle date
void set_format(const char* f);
// @cmember Setta la data alla pasqua dell'anno indicato;
void set_easter(int n = 0);
// @cmember Incrementa la data di un certo numero di giorni
TDate& operator +=(long nday);
// @cmember Decrementa la data di un certo numero di giorni

@ -2209,19 +2209,7 @@ const char* TMask::get_caption(TString& str) const
void TMask::set_caption(const char* c)
{
TToken_string captions(c);
/* for (int p = 0; p < _pages; p++)
{
const char* cap = captions.get();
if (cap == NULL) cap = captions.get(0);
xvt_vobj_set_title(_pagewin[p], (char*)cap);
const int pos = id2pos(DLG_PAGETAGS + 100 * p);
if (pos >= 0)
{
TPage_field& tag = (TPage_field&)fld(pos);
tag.set_prompt(c);
}
} */
// Kill page tags
byte p;
for ( p = 1; p <_pages; p++)

@ -3758,8 +3758,10 @@ const char* TDate_field::win2raw(
// @flag OGGI | Inserisce la data del sistema
// @flag DOMANI | Inserisce la data del giorno successivo a quella del sistema
// @flag PRIMO | Primo giorno dell'anno (01-01-aa)
// @flag ULTIMO | Ultimo giorno dell'anno (31-12-aa)
// @flag PASQUA | Giorno di pasqua
// @flag ANGELO | Lunedi' dell'angelo
// @flag NATALE | Giorno di natale (25-12-aa)
// @flag ULTIMO | Ultimo giorno dell'anno (31-12-aa)
{
TString& s = _ctl_data._park;
s = datum; s.trim();
@ -3818,6 +3820,15 @@ const char* TDate_field::win2raw(
{
g += 2;
} else
if (s.starts_with("PA")) // s == "PASQUA"
{
g.set_easter();
} else
if (s.starts_with("AN")) // s == "ANGELO"
{
g.set_easter();
++g;
} else
if (s[0] == 'A') // s == "ALTROIERI"
{
g -= 2;