I would like to display a calendar with week numbers.
Python provides a nice calendar
module that can generate such a calendar, but I can’t find a way to display week numbers.
Here is an example of the command and its output:
python -m calendar --locale fr --encoding utf-8 --type text 2024
2024
janvier février mars
Lu Ma Me Je Ve Sa Di Lu Ma Me Je Ve Sa Di Lu Ma Me Je Ve Sa Di
1 2 3 4 5 6 7 1 2 3 4 1 2 3
8 9 10 11 12 13 14 5 6 7 8 9 10 11 4 5 6 7 8 9 10
15 16 17 18 19 20 21 12 13 14 15 16 17 18 11 12 13 14 15 16 17
22 23 24 25 26 27 28 19 20 21 22 23 24 25 18 19 20 21 22 23 24
29 30 31 26 27 28 29 25 26 27 28 29 30 31
And here is what I would like to achieve:
2024
janvier février mars
Lu Ma Me Je Ve Sa Di Lu Ma Me Je Ve Sa Di Lu Ma Me Je Ve Sa Di
1 1 2 3 4 5 6 7 5 1 2 3 4 9 1 2 3
2 8 9 10 11 12 13 14 6 5 6 7 8 9 10 11 10 4 5 6 7 8 9 10
3 15 16 17 18 19 20 21 7 12 13 14 15 16 17 18 11 11 12 13 14 15 16 17
4 22 23 24 25 26 27 28 8 19 20 21 22 23 24 25 12 18 19 20 21 22 23 24
5 29 30 31 9 26 27 28 29 13 25 26 27 28 29 30 31
Is it possible to obtain this result with the Python calendar module? If it is not directly possible, how can I extend the module to get this new feature?
I’m open to a totally different approach if it makes sense.
1