Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import time
  2.  
  3. class Fecha:
  4.     # Constructor primario:
  5.     def __init__(self, aghnio, mes, dia):
  6.         self.aghnio = aghnio
  7.         self.mes = mes
  8.         self.dia = dia
  9.  
  10.     # Constructor extra:
  11.     @classmethod
  12.     def fecha_actual(cls):
  13.         fecha_local = time.localtime()
  14.  
  15.         return cls(fecha_local.tm_year, fecha_local.tm_mon, fecha_local.tm_mday)
  16.  
  17.     def __str__(self):
  18.         return '{}-{}-{}'.format(self.aghnio, self.mes, self.dia)
  19.  
  20.  
  21. if __name__ == '__main__':
  22.     fecha1 = Fecha(2019, 1, 8)
  23.     fecha2 = Fecha.fecha_actual()
  24.  
  25.     print(fecha1)
  26.     print(fecha2)