python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.34k stars 448 forks source link

Changed get_week_number() to fix a problem with the locale en_AU #1146

Open RomainBarbason opened 4 weeks ago

RomainBarbason commented 4 weeks ago

This is my first pull-request ever, so don't hesitate to give me feedback on anything

If my analysis is correct, get_week_number() made it impossible for iso-calendar to show their last week, because the week_number was fixed from 53 to 1, while it should be fixed to 52. That's why the year wasn't updated and the result was "W1 2023", it should be "W52 2023".

Hope this helps !

Fixes #1133

tomasr8 commented 3 weeks ago

Thanks for the PR! Do you think you could add some tests for this fix? Somewhere here might be a good place:

https://github.com/python-babel/babel/blob/313277af993cebfbae49d385327fc7f45e32f737/tests/test_dates.py#L715-L720

akx commented 3 weeks ago

Yep, as Tomas said, a test would be very much appreciated - the week numbering logic seems to be pretty finicky all in all...

RomainBarbason commented 2 weeks ago

Hi ! Sorry for the long wait, I had a lot of work these past weeks. I added the tests you suggested. I don't know if the Pull Request has been updated or not