Re: current week / weeks in year - best practice
- From: "Diez B. Roggisch" <deets@xxxxxxxxxxxxx>
- Date: Thu, 31 Jul 2008 15:58:56 +0200
Aljosa Mohorovic wrote:
i use this to find out current week and total number of weeks for
current year:
now = datetime.now()
weeks_in_year = int(date(now.year, 12, 31).strftime("%W"))
current_week = int(date(now.year, now.month, now.day).strftime("%W"))
is this the best way or is there a better way?
Instead of datetime.now() use date.today(), which removes a lot of
boilerplate.
int(date.today().strftime("%W"))
Apart from that, I think it's the way to go.
Diez
.
- Follow-Ups:
- Re: current week / weeks in year - best practice
- From: Aljosa Mohorovic
- Re: current week / weeks in year - best practice
- References:
- current week / weeks in year - best practice
- From: Aljosa Mohorovic
- current week / weeks in year - best practice
- Prev by Date: Re: problem when reading file
- Next by Date: Re: Function References
- Previous by thread: current week / weeks in year - best practice
- Next by thread: Re: current week / weeks in year - best practice
- Index(es):