Пример #1
0
int Usuario::getEdad(Fecha actual){
	int edad = actual.getAnio() - this->nacimiento.getAnio() ;
	if((this->nacimiento.getMes() < actual.getMes()) || (this->nacimiento.getMes() >= actual.getMes() && this->nacimiento.getDia() < actual.getDia())){
		edad -= 1;
	}
	return edad;
}
Пример #2
0
vector<Conteo> ABMConteo::GetConteoByDistritoYFecha(int idDistrito, Fecha fecha){

        vector<Conteo> conteos;

        //Conteo (((lista)ie, (distrito)ie, (eleccion)ie)i, cantidad): Arbol B+
        vector<Conteo> conteosByDistrito = this->GetConteoByDistrito(idDistrito);

        //Me traigo las elecciones de la fecha
        ABMEleccion abmElecciones = ABMEleccion();
        Fecha* f = new Fecha(fecha.getDia(), fecha.getMes(), fecha.getAnio());
        vector<Eleccion*> eleccionesByFechaYDistrito = abmElecciones.GetByFechaYDistrito(f, idDistrito);

        for(int i = 0; i < eleccionesByFechaYDistrito.size(); i++){

                int idEleccion = eleccionesByFechaYDistrito[i]->GetId();

                //Me quedo con los distritos que pertenecen a las eleccioines que busque antes
                for(int j = 0; j < conteosByDistrito.size(); j++){

					Conteo c = conteosByDistrito[i];
					if(c.GetIdEleccion() == idEleccion){
							conteos.push_back(c);
					}

                }
        }

        return conteos;
}
Пример #3
0
int main() {
  Fecha a;
  Fecha b(20, 1, 2011);

  cout << a << endl;
  cout << b << endl;
  
  if(a == b)
    cout << a << " == " << b << endl;
  else
    cout << a << " != " << b << endl;

  cin >> a;

  if(a == b)
    cout << a << " == " << b << endl;
  else
    cout << a << " != " << b << endl;

  if(a.fecha_valida())
    cout << a << "  valida" << endl;
  else
    cout << a << "  invalida" << endl;

  cout << endl;

  return 0;
}
Пример #4
0
bool operator < ( const Fecha& f1, const Fecha& f2)
{
        bool aux = false;

        if ( f1.anno() < f2.anno())
                aux =true;
        else if(f1.anno() == f2.anno() && f1.mes() < f2.mes())
                aux=true;
        else if( f1.mes() == f2.mes() && f1.dia()<f2.dia() )
                aux=true;

        return aux;

}
Пример #5
0
int main()
{
	int var;
	Fecha tmp;

	for(var = 1; var <= 2015; var++)
	{
		tmp.inicializaFecha(27, 3, var);
		if(tmp.leapyr())
			cout << var << " es bisiesto" << endl;
	}

	return 0;
}
Пример #6
0
long int operator - (const Fecha& f1, const Fecha& f2)
{
        // tm* f{};
        // f->tm_mday = f1.dia();
        // f->tm_mon = f1.mes();
        // f->tm_year = f1.anno();
        //
        // time_t tiempoilegible = mktime(f);
        // f = localtime(&tiempoilegible);
        //
        // long int f1d = f->tm_yday;
        //
        //
        // f->tm_mday = f2.dia();
        // f->tm_mon = f2.mes();
        // f->tm_year = f2.anno();
        //
        // tiempoilegible = mktime(f);
        // f = localtime(&tiempoilegible);
        //
        // long int f2d = f->tm_yday;
        //
        // return std::abs(f1d-f2d);
        tm sf1 = {0,0,0,f1.dia(),f1.mes()-1,f1.anno()-1900,0,0,0 };
	tm sf2 = {0,0,0,f2.dia(),f2.mes()-1,f2.anno()-1900,0,0,0 };
	long int tiempof1 = std::mktime(&sf1);
	long int tiempof2 = std::mktime(&sf2);

	return std::difftime(tiempof1,tiempof2)/86400;


}
Пример #7
0
void Reportes::reportePorLista(int idLista, bool guardaEncriptado, string claveEncriptado)
{
	ABMConteo *abmConteo = new ABMConteo();
	ABMEleccion* abmEleccion = new ABMEleccion();
	ABMCargo* abmCargo = new ABMCargo();
	ABMDistrito* abmDistrito = new ABMDistrito();
	std::stringstream out;

	vector<Conteo> resultados =  abmConteo->GetConteoByLista(idLista);

	if(resultados.size() == 0){
		out << "No se encontraron resultados." << endl;
		return;
	}

	//Primero ordeno por fecha de eleccion
	resultados = Reportes::OrderByFecha(resultados);


	//Agrupo por fecha de eleccion
	vector< vector<Conteo> > resAgrupados;
	vector<Conteo> cs;
	cs.push_back(resultados[0]);
	resAgrupados.push_back(cs);
	int idEleccionActual = resultados[0].GetIdEleccion();

	//Tengo que agrupar por eleccion
	for(int i = 1; i < resultados.size(); i++){

		  Conteo conteo = resultados[i];

		  if(conteo.GetIdEleccion() == idEleccionActual){

			resAgrupados[resAgrupados.size() - 1].push_back(conteo);
		  }
		  else{	//Nuevo grupo de eleccion

			  vector<Conteo> cs;
			  cs.push_back(conteo);
			  resAgrupados.push_back(cs);
			  idEleccionActual = conteo.GetIdEleccion();

		  }

	}

	for(int i = 0; i < resAgrupados.size(); i++){

		vector<Conteo> aux = Reportes::OrderByCantidadVotos(resAgrupados[i]);
		resAgrupados[i] = aux;
	}

	out << endl << endl << endl;

	for(int i = 0; i < resAgrupados.size(); i++){

		vector<Conteo> cs = resAgrupados[i];

		if(resAgrupados.size() > 0){

			Conteo conteo = cs[0];
			Eleccion* e = abmEleccion->GetEleccion(conteo.GetIdEleccion());
			string cargo = abmCargo->GetCargo(e->GetIdCargo())->GetNombre();

			Fecha fecha = e->GetDate().getStrFecha();

			out << "Eleccion: (" << fecha.getFriendlyStr() << " - " << cargo << ")" << endl;

			for(int j = 0; j < cs.size(); j++){
				Conteo res = cs[j];
				out << "		Distrito: " << res.GetIdDistrito() << " tiene " << res.GetCountVotos() << " votos." << endl;
			}
		}
	}

	if (guardaEncriptado)
	{
		string fileName = ConfigurationMananger::getInstance()->getReportFileDirectory().append("ReportexLista");
		fileName.append(Helper::IntToString(Identities::GetNextNroReporteXLista())).append(".ecr");

		string reporteEncriptado = Vigenere::encriptar(claveEncriptado, out.str());
		ofstream file;
		file.open(fileName.c_str(), ios::app);
		file.write(reporteEncriptado.c_str(), reporteEncriptado.size());
		file.close();

		cout << "Reporte encriptado correctamente" << endl;
	}
	else{
		cout << out.str();
	}

	delete abmConteo;
	delete abmEleccion;
	delete abmCargo;
	delete abmDistrito;

}
Пример #8
0
bool operator ==(const Fecha& f1, const Fecha& f2)
{
        return (f1.dia()==f2.dia() && f1.mes() && f2.mes() && f1.anno() ==f2.anno());
}
Пример #9
0
int main()
{
	const Cadena NombreM("Jose Manuel Barba Gonzalez");
	Fecha fecM(21,2,1982);
	Fecha fpubli(1,1,1970);
	Fecha fexp(3,7,2015);
	const Fecha fString("1/1/1970");
	Fecha f;
	const char *user = "******";
	Cadena art_id("110");
	Cadena art_nom("Programación C");
	Cadena cadM(user);
	//Numero Num_tjtM("1234 9840 9482 3847");
//	Numero Num_tjtM("378282246310005");

	Cadena userid("001");
	Cadena userNom("Jose M");
	Cadena userApll("Barba Gonzalez");
	Cadena userDir("su casa");
//	const Clave userPass("holas");
	//istringstream isM("2/4/2006");
	//ostringstream os("");
	cout << "---" << endl;
	//isM >> f;

/*	Usuario userM(userid,userNom,userApll,userDir,userPass);
	Tarjeta TjtM(Num_tjtM,userM,fexp);
	Autor autM(userNom,userApll,userDir);
	Articulo::Autores autores = crea_autores(autM);
	Libro artM(autores,art_id,art_nom,fpubli,50.55,200,100);
	InformeDigital InfDigM(autores,art_id,art_nom,fpubli,50.55,fexp);
*/
	cout << "Main\n" << NombreM << endl << cadM << "." << endl;
	cout << "---Cadena---" << endl;

	cout << "Extraccion: una palabra --- ";
	istringstream is("bueno bonito barato");
	Cadena c("algo");
	is >> c;
	if(c == "bueno" && is.peek() == ' ') cout << "OK." << endl;
	cout << c << endl;

	cout << endl << "---Fecha---" << endl;

	cout << "Fecha de Nacimiento: "; fecM.visualizar();
	cout << "Fecha como cadena: "; fString.visualizar();
Fecha g(--fecM);g.visualizar();g.restadias(3);g.visualizar();
++g;g.visualizar();g.sumadias(2);g.visualizar();
	cout << "---" << endl;
	//f.visualizar();
	//cout << f;

/*	cout << "\n---Articulo Libro---\n" << artM;
	cout << "\n---Articulo InformeDigital---\n" << "A la venta hasta el "; InfDigM.imp_esp(os);
	cout << "\n---Tarjeta---\n" << TjtM.tarjeta() << endl;
	cout << "\n---Usuario---\n" << userM.id() << "|" << userM.nombre() << " " << userM.apellidos() << "|" << userM.direccion() << "|" << userPass.clave() << endl;

	if(userPass.verifica("holas"))
		cout << "Verificada" << endl;
	else
		cout << "No Verificada" << endl;
*/
	return 0;
}
Пример #10
0
int masVieja(Fecha& fecha1, Fecha& fecha2){
	return fecha1.comparaRef(fecha2);
}
Пример #11
0
int masVieja(Fecha fecha1, Fecha fecha2){
	return fecha1.compara(fecha2);
}
bool TarjetaMedioBoleto::pagarBoleto(Colectivo colectivo, Fecha fecha){
    if( fecha.hora() < 6 )
         return TarjetaBase::pagarBoleto(colectivo, fecha, TarjetaBase::BOLETO_COMUN,
                                         TarjetaBase::BOLETO_TRANSBORDO);
    else return TarjetaBase::pagarBoleto(colectivo, fecha, BOLETO_COMUN, BOLETO_TRANSBORDO);
}
Пример #13
0
Fecha::Fecha(const Fecha& base, int delta) {
	_dia = base.dia();
	_mes = base.mes();
	_anyo = base.anyo();
}