Needs programming tip using date
Gerhard Häring
gh at ghaering.de
Tue Aug 5 12:26:55 EDT 2003
Raaijmakers, Vincent (IndSys, GE Interlogix) wrote:
> I think this is a bit of a newbie question in the dates area.
Ok, the first thing you should do is download and install the eGenix
BASE package [1]. If you have a half-way decent operating system, you
can also install it via the package manager or ports system ;-)
> So before I end up in very ugly coding,
> What is THE/recommended way in checking if a date formatted as "08/05/2003", so "month/day/year"
> is the date of today or a date of the current week?
from mx.DateTime import DateTimeFrom, now
dt = DateTimeFrom("08/05/2003")
if dt.iso_week[1] == now().iso_week[1]:
print "date is in current week"
You'll want to check if the definition of iso_week matches your
definition of 'week'. [2]
-- Gerhard
[1] http://www.egenix.com/files/python/eGenix-mx-Extensions.html
[2] http://www.egenix.com/files/python/mxDateTime.html
More information about the Python-list
mailing list