Skip to content

Instantly share code, notes, and snippets.

@migonzalvar
Created June 26, 2014 08:59
Show Gist options
  • Save migonzalvar/41d9d741f5f7ebe102e4 to your computer and use it in GitHub Desktop.
Save migonzalvar/41d9d741f5f7ebe102e4 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
""" Calcula los días transcurridos desde una fecha.
"""
import datetime
DAY_LABELS = "Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo".split(',')
user_date = input('Fecha> ')
day, month, year = [int(s) for s in user_date.split('-')]
date = datetime.date(year, month, day)
today = datetime.date.today()
print('Fue: %s' % DAY_LABELS[date.weekday()])
diff = today - date
diff_years, diff_days = divmod(diff.days, 365)
diff_months, diff_days = divmod(diff_days, 30)
tpl = '%s años, %s meses y %s días'
data = diff_years, diff_months, diff_days
print(tpl % data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment