I suspect there is no 'standard' definition of week number.  

E.g. if the year begins on a Wednesday, is the following Monday part
of week 1 or week 2?

Once you decide, you can design a calculation starting with
"some_date_object.dayOfYear()" which will give you the day number in
the range 1 to 365 (or 366).

The simplest algorithm would be to say days 1-7 are week 1, 8-14
are week 2, etc.  In that case 

             ((some_date_object.dayOfYear() - 1) / 7) + 1

(or in dtml)

  <dtml-var "((some_date_object.dayOfYear() - 1) / 7) + 1">

will compute a week number (in the range 1 to 53).

If your weeks must begin on Sundays, or Mondays, or whatever, you'll
have to first request the dow() from the first day of the relevant
year, and do a calculation based on how far into the week the first
calendar day of the year falls.  If you want help with that,
describe the algorithm you want to use.

Good luck.

Arjan Scherpenisse <[EMAIL PROTECTED]> writes:

> Hello,
> i want to retrieve the number of the week from a DateTime object. Is
> there any way to do this? I've looked through DateTime.py but i
> couldnt find anything usefull, is there some algorithm to get this?

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to