Classe ritorna sempre vero
-
Ho creato questa classe, l'ho provata sul c9 e mi ritorna sempre vero.
Qualcuno mi saprebbe dire perche'?
C'e' qualche altro modo per scriverla magari un po' piu' professionale?
Grazie mille@
#include "festivita.h"
#include <QDate>Festivita::Festivita()
{}
bool Festivita::festivo(QDate d)
{
// QDate d;//Data passata come parametro
//int mese = d.month();
int anno = d.year();
//int giorno = d.day();
QDate apasqua(pasqua(anno).year(),pasqua(anno).month(),pasqua(anno).day());if (d.day()==1 && d.month()==1) return(true);// Primo dell'anno if (d.day()==6 && d.month()==1) return(true);// Epifania if (d==apasqua.addDays(1)) //if (d.day()==(apasqua.day()) && d.month()==apasqua.month()) //if (d.day()==(pasqua(anno).day()) && d.month()==pasqua(anno).month()) return(true);// Lunedi dell'Angelo if (d.day()==25 && d.month()==04) return(true);// Anniversario della liberazione if (d.day()==1 && d.month()==5) return(true);// Festa del lavoro if (d.day()==2 && d.month()==6) return(true);// Proclamazione della repubblica if (d.day()==29 && d.month()==6) return(true);// SS. Pietro e Paolo if (d.day()==15 && d.month()==8) return(true);// Assunzione if (d.day()==1 && d.month()==11) return(true);// Ognissanti if (d.day()==8 && d.month()==12) return(true);// Immacolata concenzione if (d.day()==25 && d.month()==12) return(true);// Nativita' if (d.day()==26 && d.month()==12) return(true);// S.Stefano
}
bool Festivita::soppresso(QDate d)
{
//int mese = d.month();
int anno = d.year();
//int giorno = d.day();
QDate apasqua(pasqua(anno).year(),pasqua(anno).month(),pasqua(anno).day());
if (d.day()==19 && d.month()==3)
return(true);// S.Giuseppe
if (d==apasqua.addDays(39))
return(true);// Ascensione N.S.
if (d==apasqua.addDays(60))
return(true);// Corpus Domini
if (d.day()==4 && d.month()==11)
return(true);// Unita' Nazionale
if (d.day()==10 && d.month()==12)
return(true);// Madonna di Loreto
}QDate Festivita::pasqua(int anno)
{
int a;
int b;
int c;
int p;
int q;
int r;
QDate dat;
a= anno % 19;
b=anno / 100;
c=anno % 100;
p = ((19 * a + b - (b / 4) - ((b - ((b + 8) / 25) + 1) / 3) + 15) % 30);
q = ((32 + 2 * ((b % 4) + (c / 4)) - p - (c % 4)) % 7);
r = (p + q - 7 * ((a + 11 * p + 22 * q) / 451) + 114);
dat.setDate(anno,(r/31),((r % 31)+1));
return dat;
}
@[Edit: @ tags; mlong]