Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 22, 2020 21:57
Show Gist options
  • Save parzibyte/e5f8e77909f4b0b06800cc59433927c3 to your computer and use it in GitHub Desktop.
Save parzibyte/e5f8e77909f4b0b06800cc59433927c3 to your computer and use it in GitHub Desktop.
"""
https://parzibyte.me/blog
"""
def es_bisiesto(anio: int) -> bool:
return anio % 4 == 0 and (anio % 100 != 0 or anio % 400 == 0)
def obtener_dias_del_mes(mes: int, anio: int) -> int:
# Abril, junio, septiembre y noviembre tienen 30
if mes in [4, 6, 9, 11]:
return 30
# Febrero depende de si es o no bisiesto
if mes == 2:
if es_bisiesto(anio):
return 29
else:
return 28
else:
# En caso contrario, tiene 31 días
return 31
# Probamos
mes = 9
anio = 2020
dias = obtener_dias_del_mes(mes, anio)
print(dias)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment