A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/348158.html below:

Find day of week from month and year

Find day of week from month and yearPaul McGuire ptmcg at austin.rr.com
Sat Sep 3 10:27:48 EDT 2005
Donn,

You didn't look closely enough at those results.  The OP's point was
that he did not know how to set all the tuple values correctly.  Here's
a clearer example, I think:

import time
print time.asctime((2005,9,1,0,0,0,0,0,0))
print time.asctime((2005,9,1,0,0,0,1,0,0))
print time.asctime((2005,9,1,0,0,0,2,0,0))
print time.asctime((2005,9,1,0,0,0,3,0,0))

Prints:
Mon Sep 01 00:00:00 2005
Tue Sep 01 00:00:00 2005
Wed Sep 01 00:00:00 2005
Thu Sep 01 00:00:00 2005

No matter what time zone you're in, Sep 1, 2005 can't be all those days
of the week! :)

Your code works because you use mktime, which appears to ignore the
dayOfWeek element of the input tuple, as shown by the following:

print time.asctime(time.gmtime(time.mktime((2005,9,1,0,0,0,0,0,0))))
print time.asctime(time.gmtime(time.mktime((2005,9,1,0,0,0,1,0,0))))
print time.asctime(time.gmtime(time.mktime((2005,9,1,0,0,0,2,0,0))))
print time.asctime(time.gmtime(time.mktime((2005,9,1,0,0,0,3,0,0))))

Prints:
Thu Sep 01 06:00:00 2005
Thu Sep 01 06:00:00 2005
Thu Sep 01 06:00:00 2005
Thu Sep 01 06:00:00 2005

-- Paul


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4