Finding out the weekday

Jorge Godoy godoy at metalab.unc.edu
Wed Mar 26 01:03:25 CET 2003


Alex Martelli <aleax at aleax.it> writes:

> Jorge Godoy wrote:
>
>> Is there any Python module that given a particular date it returns me
>> the day of the week? I'm needing it for some special calculations
>> involving dates...
>
>>>> import calendar
>>>> calendar.weekday(2003,3,25)
> 1
>>>> print calendar.weekday.__doc__
> Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12),
>        day (1-31).
>>>>

This is exactly what I was looking for.

I had found the other answers (weekday[6]...)  before, but I wanted to
see if there was something more interesting. It didn't occurred me to
look for 'calendar'... :-\


Thanks,
-- 
Godoy.     <godoy at metalab.unc.edu>




More information about the Python-list mailing list