Friday, October 15, 2021

Python strptime Russian month discrepency between Linux and Windows

There is more than a way to write the month in any given language for example in Russian the month September can be written in more than one way

But on Python's implementation of strptime there is a difference in how the windows  or Linux OS perceives the month. 

Just run this Python code in Windows and Linux and see the difference for yourself

import locale

import datetime

locale.setlocale(locale.LC_ALL, "ru_RU")

datetime.datetime.strptime('2021-сентября-18', '%Y-%B-%d')

datetime.datetime.strptime('2021-сентябрь-18', '%Y-%B-%d')


In Windows "сентябрь" works whereas in Linux "сентября" works. This is same for all the months since most of them end in either "рь"  or "ря"

No comments: