Re: [Zope] Retrieving the week number with DateTime
"DC" == David Coe [EMAIL PROTECTED] writes: DC I suspect there is no 'standard' definition of week number. You're wrong. According to the calendar FAW (thanks, Google:-): 5.7 What is the week number? International standard IS-8601 (mentioned in section 5.6) assigns a number to each week of the year. A week that lies partly in one year and partly in another is assigned a number in the year in which most of its days lie. This means that Week 1 of any year is the week that contains 4 January, or equivalently Week 1 of any year is the week that contains the first Thursday in January. Most years have 52 weeks, but years that start on a Thursday and leap years that start on a Wednesday have 53 weeks. Regards, Rob Hooft -- = [EMAIL PROTECTED] http://www.hooft.net/people/rob/ = = RD, Nonius BV, Delft http://www.nonius.nl/ = = PGPid 0xFA19277D == Use Linux! = ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] Retrieving the week number with DateTime
There is a standard for calculating weeknumbers. It is in an ISO standard, but I do not know the number of it. I implemented it in another application a while back. I got it from the NNI, the Dutch national 'ISO' which follows the ISO standards on this. The standard: the first day for calculating is the monday. If four or more days are in the old year, then the week is the last week of the old year. If four or more days are in the new year then it is the first week of a new year. I concluded from this that the Thursday is crucial: if it in a new year then it is week 1. Gijs Reulen -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]Namens Tim Cook Verzonden: donderdag 3 augustus 2000 6:34 Aan: David Coe; Zope List Onderwerp: Re: [Zope] Retrieving the week number with DateTime David Coe wrote: I suspect there is no 'standard' definition of week number. I asked this on a list with a bunch of accounting types and got the same reply. It is 'generally' associated with payroll or tax periods. Once you have a 'definition' for Jan 1 of the current year and the day of the week that 'your' week starts on then you could use David's suggestion(s). Either you or your customer has to define those two things first. -- Tim Cook -- FreePM Project Coordinator - http://www.freepm.org OS Healthcare Alliance Supporter - http://www.oshca.org ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Retrieving the week number with DateTime
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] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Retrieving the week number with DateTime
David Coe wrote: I suspect there is no 'standard' definition of week number. I asked this on a list with a bunch of accounting types and got the same reply. It is 'generally' associated with payroll or tax periods. Once you have a 'definition' for Jan 1 of the current year and the day of the week that 'your' week starts on then you could use David's suggestion(s). Either you or your customer has to define those two things first. -- Tim Cook -- FreePM Project Coordinator - http://www.freepm.org OS Healthcare Alliance Supporter - http://www.oshca.org ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )