Created
June 26, 2014 08:59
-
-
Save migonzalvar/41d9d741f5f7ebe102e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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