Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. def anioB(anio):
  2. '''
  3. Determina si un año es bisiesto o no
  4. '''
  5. if anio % 4 is 0 and anio % 100 is not 0 or anio % 400 is 0:
  6. return True
  7. else:
  8. return False
  9.  
  10. def diaSemana(anio,mes,dia):
  11. '''
  12. Calcula el día que cae un determinado día, de un mes, de un año
  13. '''
  14. digitos_siglo=anio//100
  15. digitos_año=anio%100
  16. valor=digitos_año + math.floor(digitos_año / 4)
  17. if digitos_siglo == 18:
  18. valor=valor+2
  19. elif digitos_siglo == 20:
  20. valor+=6
  21. anio_bisiesto=anioB(anio)
  22. if mes == "Enero" and anio_bisiesto == False:
  23. valor+=1
  24. elif mes == "Febrero" and anio_bisiesto:
  25. valor+=3
  26. elif mes == "Febrero" and anio_bisiesto == False:
  27. valor+=4
  28. elif mes == "Marzo" or mes == "Noviembre":
  29. valor+=4
  30. elif mes == "Mayo":
  31. valor+=2
  32. elif mes == "Junio":
  33. valor+=5
  34. elif mes == "Agosto":
  35. valor+=3
  36. elif mes == "Octubre":
  37. valor+=1
  38. elif mes == "Setiembre" or mes == "Diciembre":
  39. valor+=6
  40.  
  41. valor=(valor+dia)%7
  42.  
  43. if valor == 1:
  44. return "Domingo"
  45. elif valor==2:
  46. return "Lunes"
  47. elif valor==3:
  48. return "Martes"
  49. elif valor==4:
  50. return "Miércoles"
  51. elif valor==5:
  52. return "Jueves"
  53. elif valor==6:
  54. return "Viernes"
  55. elif valor==0:
  56. return "Sábado"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement