Our first working day of the week is sunday. Using the solutions above gave the following : if I convert 15/12/2009 to week number the conversion week is 51 which is OK. If I convert 13/12/2009 (Sunday) to week number the result is week No. 50 which does not confirm with our working calendar.
How to set Sunday as the first day of the week so that the conversion will confirm with our working calender?
Thanks
Isocalendar is for the ISO date standard which is a pretty specific thing. You could take the code above and replace the bottom output line with
OUT = datetime.date(year, month, day).strftime("%U")
Which will give you the week starting Sunday.
The other thing you’ll run into is if your standards for what ‘week 1’ is differ. If Jan 1st is a Tuesday is that week 1, or do you need to wait for a Monday? If that Tuesday is week 1 by your standards, then what if Jan 1st is a Friday, is that still week 1? The ISO date has a standard for this but yours might differ, and I’m not sure how the strftime functions determine it.