Needs programming tip using date
Bernard Delmée
bdelmee at advalvas.REMOVEME.be
Tue Aug 5 14:39:05 EDT 2003
> 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?
Gotta love 2.3:
import datetime
sdate = '08/08/2003'
(d,m,y) = map(int,sdate.split('/'))
# assumming dd/mm/yyyy mask
ddate = datetime.date( y,m,d )
sweek = ddate.isocalendar()[1]
refwk = ddate.today().isocalendar()[1]
same_week = sweek == refwk
Cheers,
Bernard.
More information about the Python-list
mailing list