Finding out the weekday

John Machin sjmachin at lexicon.net
Wed Mar 26 03:15:51 EST 2003


"Terry Reedy" <tjreedy at udel.edu> wrote in message news:<1ZKcnQPKB9e4Kh2jXTWcpQ at comcast.com>...
> "Jorge Godoy" <godoy at metalab.unc.edu> wrote in message
> news:86adfjz286.fsf at ieee.org...
> > 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...
> 
> don't know if new datetime module has that.  But formula is easy to
> program.  This has been asked various times on various newgroups.
> Google 'day week formula', first hit says
> "
> To add to Ben's article (appended below), John Conway's
> method is by far the easiest to use. A general method
> of finding the special day of the week for any year (what
> Conway calls 'Doomsday') is as follows: Write the year
[snip]
> which is the day of the week (Sunday = 0, Saturday = 6). Thus,
> Monday=1 is the Doomsday for 1994.
> 
> E is the century number, which repeats on a 400 year cycle.
> This century E=3; in 16YY and 20YY it is 2; in 17YY and 21YY
> it is 0, and in 18YY and 22YY it is 5. It goes back to 3 again
> in 23YY.
> "
> 
> Terry J. Reedy

What is this "Doomsday" thingy? The above description certainly shows
that it is a function of the year only, i.e. doesn't depend on the day
and the month -- which would appear not to be what the OP was looking
for e.g day_of_week(today()) returns "Wednesday" (in my
timezone/locale combination) and will return "Thursday" tomorrow.




More information about the Python-list mailing list