3 ms·
Note that `strftime` (and implementations dependent on it - hello Python!) do not implement ISO week numbers. In `strftime` all days preceding the first Sunday/
by mikro2nd 7y ago
Note that `strftime` (and implementations dependent on it - hello Python!) do not implement ISO week numbers. In `strftime` all days preceding the first Sunday/Monday (depending which date-code you pass to the function) in a year are classified as "Week 0" as opposed to the ISO definition. This means that `strftime` week numbers are generally 1 less than the ISO week number.
As serendipity would have it I was delving into this issue just this morning... :O
- jontro 7y agoYeah, there is a lot of languages missing iso week support. Probably because it's not used in the US as much. Found this gist for getting using it in Power BI a couple of weeks ago https://gist.github.com/r-k-b/18d898e5eed786c9240e3804b167a5ca https://gist.github.com/r-k-b/18d898e5eed786c9240e3804b167a5...
- fanf2 7y agoHere is how to format an ISO week date with strftime: “%G-W%V-%u” This is in POSIX https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/strftime.html https://pubs.opengroup.org/onlinepubs/9699919799.2018edition... and C99 http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf Python’s documentation explicitly says it only describes the C89 formatting codes and that C99 has more features. https://docs.python.org/2.7/library/datetime.html#strftime-strptime-behavior https://docs.python.org/2.7/library/datetime.html#strftime-s...
- bshipp 7y agoWhile it's fine and good that ISO has defined week numbers, it has been less than helpful when working with North American firms whose weeks start on Sunday and who expect January 1st to be week 1. I've ended up having to write custom code to handle this in my programs as most generic libraries support ISO and not much else.
- petters 7y agoPython 3.6+ added this.