Aggiunte funzioni per settare giorno, mese, anno e per mettere la data
all'ultimo giorno del mese git-svn-id: svn://10.65.10.50/trunk@195 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1d89b5cf66
commit
a947a1c109
@ -99,6 +99,37 @@ TDate::TDate(int day, int month, int year)
|
||||
}
|
||||
}
|
||||
|
||||
void TDate::set_end_month()
|
||||
// parse_filastrok(
|
||||
// "trenta giorni case novembre
|
||||
// con april, giugno e settembre
|
||||
// case ventotto ce n'e' uno
|
||||
// per default ce n'ha trentuno");
|
||||
{
|
||||
int d;
|
||||
switch(month())
|
||||
{
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 11:
|
||||
d = 30;
|
||||
break;
|
||||
case 2:
|
||||
d = year() % 4 ? 28 : 29;
|
||||
break;
|
||||
default:
|
||||
d = 31;
|
||||
break;
|
||||
}
|
||||
_val = makedata(d,month(),year());
|
||||
}
|
||||
|
||||
void TDate::set_day(int n) { _val = makedata(n, month(), year()); }
|
||||
void TDate::set_month(int n) { _val = makedata(day(), n, year()); }
|
||||
void TDate::set_year(int n) { _val = makedata(day(), month(), n); }
|
||||
|
||||
|
||||
|
||||
TDate::operator const char*() const
|
||||
{
|
||||
|
@ -34,11 +34,18 @@ public:
|
||||
int day() const ; // Ritorna il giorno
|
||||
int month() const ; // Ritorna il mese
|
||||
int year() const ; // Ritorna l'anno
|
||||
void addmonth(int nmonth = 1); // Aggiunge dei mesi
|
||||
void addyear(int nyear = 1); // Aggiunge degli anni
|
||||
bool ok() const; // Vero se la data e' corretta
|
||||
void addmonth(int nmonth = 1); // Aggiunge dei mesi
|
||||
void addyear(int nyear = 1); // Aggiunge degli anni
|
||||
bool ok() const; // Vero se la data e' corretta
|
||||
static bool isdate(const char*); // Vero se la stringa passata e' una data corretta
|
||||
|
||||
void set_end_month(); // setta il giorno del mese all'ultimo possibile
|
||||
// implementando la filastrocchina
|
||||
|
||||
void set_day(int n);
|
||||
void set_month(int n);
|
||||
void set_year(int n);
|
||||
|
||||
// @DES Ridefiniti gli operatori: += -= ++ -- >> e <<
|
||||
// @FPUB
|
||||
TDate& operator +=(const long nday) { _val += nday; return *this; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user