Aggiunto metodino per vedere se siamo a fine mese

git-svn-id: svn://10.65.10.50/trunk@283 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-09-23 10:27:04 +00:00
parent 0ee8f9c3d0
commit d6ed7209ee
2 changed files with 17 additions and 6 deletions

View File

@ -99,7 +99,7 @@ TDate::TDate(int day, int month, int year)
}
}
void TDate::set_end_month()
int TDate::last_day(int month, int year)
// parse_filastrok(
// "trenta giorni case novembre
// con april, giugno e settembre
@ -107,7 +107,7 @@ void TDate::set_end_month()
// per default ce n'ha trentuno");
{
int d;
switch(month())
switch(month)
{
case 4:
case 6:
@ -116,21 +116,29 @@ void TDate::set_end_month()
d = 30;
break;
case 2:
d = year() % 4 ? 28 : 29;
d = year % 4 ? 28 : 29;
break;
default:
d = 31;
break;
}
_val = makedata(d,month(),year());
return d;
}
void TDate::set_end_month()
{
_val = makedata(last_day(month(),year()),month(),year());
}
bool TDate::is_end_month()
{
return day() == last_day(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
{
return string(4);

View File

@ -26,6 +26,8 @@ class TDate : TObject
friend bool operator ==(const TDate& a, const TDate& b);
friend bool operator !=(const TDate& a, const TDate& b);
static int last_day(int month, int year);
public:
// @FPUB
char* string(int yeardgts = 4, char sep = '-') const ;
@ -39,6 +41,7 @@ public:
bool ok() const; // Vero se la data e' corretta
static bool isdate(const char*); // Vero se la stringa passata e' una data corretta
bool is_end_month();
void set_end_month(); // setta il giorno del mese all'ultimo possibile
// implementando la filastrocchina