Tempus

Last updated: May 15th, 20192019-05-15Project preview
In [5]:
from tempus import Tempus

dates = [
    {
        "contract": "001",
        "start_date": Tempus("2016/06/15"),
        "term": 12
    },
    {
        "contract": "002",
        "start_date": Tempus("2013/03/14"),
        "term": 12
    },
    {
        "contract": "003",
        "start_date": Tempus("2014/05/06"),
        "term": 12
    },
    {
        "contract": "004",        
        "start_date": Tempus("2012/09/12"),
        "term": 24
    },
    {
        "contract": "005",        
        "start_date": Tempus("2018/10/08"),
        "term": 12
    },
]
print('Contratos vencidos:')
for date in dates:
    
    term = date['term']
    end_date = date['start_date'].add(months=term, years=1)
    
    if end_date.get() < Tempus().today():
        print('\tContrato', date['contract'], 'expiró el', end_date.get())
Contratos vencidos:
	Contrato 001 expiró el 2018-06-15
	Contrato 002 expiró el 2015-03-14
	Contrato 003 expiró el 2016-05-05
	Contrato 004 expiró el 2015-09-12
In [ ]:
 
Notebooks AI
Notebooks AI Profile20060