From a947a1c1096d6d86c16b8e540d2cd983b99ec18d Mon Sep 17 00:00:00 2001 From: villa Date: Thu, 8 Sep 1994 14:40:02 +0000 Subject: [PATCH] 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 --- include/date.cpp | 31 +++++++++++++++++++++++++++++++ include/date.h | 13 ++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/include/date.cpp b/include/date.cpp index a950ff91d..c933fbe30 100755 --- a/include/date.cpp +++ b/include/date.cpp @@ -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 { diff --git a/include/date.h b/include/date.h index a1f6b4e9e..ca41b3598 100755 --- a/include/date.h +++ b/include/date.h @@ -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; }