[pyar] Weekday de fechas muy viejas

Daniel dmlistapython en gmail.com
Mie Mayo 4 10:13:40 ART 2016


El 4 de mayo de 2016, 9:39, Ariel Rossanigo <arielrossanigo en gmail.com>
escribió:

> Hola Matias; supongo que el problema viene porque los módulos de Python
> trabajan con el calendario Gregoriano extendido [0] y en realidad ese
> calendario antes de 1582 no existía; existía el juliano que tiene algunas
> diferencias de días.
>
> Hay una fórmula para corregir eso, acá la podés ver [1]. Quedaría más o
> menos así:
>
> In [1]: import datetime
>
> In [2]: year = 156
>
> In [3]: d = datetime.datetime(year,1,26)
>
>
> In [4]: (d.weekday() + (year//100) - (year//400) - 2)%7
> Out[4]: 6
>
>
> Saludos
>
> [0]: https://docs.python.org/2/library/calendar.html#module-calendar
> Most of these functions and classes rely on the datetime
> <https://docs.python.org/2/library/datetime.html#module-datetime> module
> which uses an idealized calendar, the current Gregorian calendar
> indefinitely extended in both directions. This matches the definition of
> the “proleptic Gregorian” calendar in Dershowitz and Reingold’s book
> “Calendrical Calculations”, where it’s the base calendar for all
> computations.
> [1]:
> https://en.wikipedia.org/wiki/Gregorian_calendar#Difference_between_Gregorian_and_Julian_calendar_dates
>

¡Que interesante!
ahora... no me parece un comportamiento esperado de la función. Debería dar
error antes de ese año, o corregirlo
después salen errores como el que acabo de encontrar en este mismo hilo
calculando los tiempos :P
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20160504/6d613ebc/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: gmail.jpg
Type: image/jpeg
Size: 11719 bytes
Desc: no disponible
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20160504/6d613ebc/attachment-0001.jpg>


Más información sobre la lista de distribución pyar