def test():
   print('\tIniciando Test...')

   d = int(input("Ingrese Dia: "))

   mes = int(input("Ingrese Mes: "))

   a = int(input("Ingrese Año: "))

   h = int(input("Ingrese Hora: "))

   m = int(input("Ingrese Minutos: "))

   s = int(input("Ingrese Segundos: "))

   testInstancia = FechaHora(d,mes,a,h,m,s)
   print('Instancia 1:')
   print(testInstancia)
   print('Instancia 2:')
   testInstancia2 = FechaHora(12,3,'año',h,m,s)#Tipo no valido no crea instancia
   testInstancia3 = FechaHora(15,6,2020,12,11,30)
   testInstancia4 = Hora(12,10,30)
   print('Suma de 2 instancias:')
   f = testInstancia3+testInstancia4#La suma ajustara la fecha
   print(f)
   print('\t Finalizando test...')
 def __add__(self, unaHora):
     aux = Hora()
     if type(aux) == type(unaHora):
         FechaRes = FechaHora(self.getDia(), self.getMes(), self.getAño(),
                              self.getHora() + unaHora.getHora(),
                              self.getMinutos() + unaHora.getMinutos(),
                              self.getSegundos() + unaHora.getSegundos())
         return FechaRes
Exemple #3
0
 def __radd__(self, otraFecha):
     aux = Hora()
     if type(aux) == type(otraFecha):
         suma = FechaHora(self.__dia, self.__mes, self.__year,
                          self.__hora + otraFecha.getHora(),
                          self.__minutos + otraFecha.getMinutos(),
                          self.__segundos + otraFecha.getSegundos())
     elif type(otraFecha) == int:
         suma = FechaHora(self.__dia + otraFecha, self.__mes, self.__year,
                          self.__hora, self.__minutos, self.__segundos)
     return suma
 def __radd__(self, dato):
     aux = Hora()
     if type(aux) == type(dato):
         FechaRes = FechaHora(self.getDia(), self.getMes(), self.getAño(),
                              self.getHora() + dato.getHora(),
                              self.getMinutos() + dato.getMinutos(),
                              self.getSegundos() + dato.getSegundos())
         return FechaRes
     elif type(dato) == int:
         FechaRes = FechaHora(self.getDia() + dato, self.getMes(),
                              self.getAño(), self.getHora(),
                              self.getMinutos(), self.getSegundos())
         return FechaRes
Exemple #5
0
    d = 12  #ValidaEntero('Ingrese dia: ')
    mes = 4  #ValidaEntero('Ingrese mes: ')
    a = 2021  #ValidaEntero('Ingrese año: ')
    h = 16  #ValidaEntero('Ingrese hora: ')
    m = 25  #ValidaEntero('Ingrese minutos: ')
    s = 55  #ValidaEntero('Ingrese segundos: ')

    f = FechaHora(d, mes, a, h, m, s)
    print(f)
    print()

    h1 = 16  #ValidaEntero('Ingrese hora: ')
    m1 = 26  #ValidaEntero('Ingrese minutos: ')
    s1 = 30  #ValidaEntero('Ingrese segundos: ')

    r = Hora(h1, m1, s1)
    print(r)
    print()
    os.system('pause')

    print()
    f2 = f + r
    print(f2)
    print()
    os.system('pause')

    print()
    f3 = r + f
    print(f3)
    print()
    os.system('pause')
Exemple #6
0
    if flag == True:
        return FechaHora(d, mes, a, h, m, s)
    else:
        return [h, m, s]


if __name__ == '__main__':

    f = ingresarDatos(True)
    print(f)

    input()

    ingresarDatos()  #como estos datos no los uso no le asigno una variable
    r = Hora(f.getHora(), f.getMinutos(), f.getSegundos())
    print(r)

    input()

    f2 = f + r
    print(f2)

    input()

    f3 = r + f
    print(f3)

    input()

    f4 = f3 - 1
    input('Presiona ENTER para continuar...')


if __name__ == '__main__':
    d = int(input("Ingrese Dia: "))
    mes = int(input("Ingrese Mes: "))
    a = int(input("Ingrese Año: "))
    h = int(input("Ingrese Hora: "))
    m = int(input("Ingrese Minutos: "))
    s = int(input("Ingrese Segundos: "))
    f = FechaHora(d, mes, a, h, m, s)
    f.Mostrar()
    input()
    h1 = int(input("Ingrese Hora: "))
    m1 = int(input("Ingrese Minutos: "))
    s1 = int(input("Ingrese Segundos: "))
    r = Hora(h1, m1, s1)
    r.Mostrar()
    input()
    f2 = f + r
    f2.Mostrar()
    input()
    f3 = r + f
    f3.Mostrar()
    input()
    f4 = f3 - 1  # Al restar un número entero a un objeto FechaHora se debe restar la cantidad de días indicada por el número entero
    f4.Mostrar()
    f4 = 1 + f2  # suma un día a un objeto FechaHora
    f4.Mostrar()
    input()
    test()