How can I rewrite following clause:
if u'января' in date_category['title']:
month = 1
elif u'февраля' in date_category['title']:
month = 2
elif u'марта' in date_category['title']:
month = 3
elif u'апреля' in date_category['title']:
month = 4
elif u'мая' in date_category['title']:
month = 5
elif u'июня' in date_category['title']:
month = 6
elif u'июля' in date_category['title']:
month = 7
elif u'августа' in date_category['title']:
month = 8
elif u'сентября' in date_category['title']:
month = 9
elif u'октября' in date_category['title']:
month = 10
elif u'ноября' in date_category['title']:
month = 11
elif u'декабря' in date_category['title']:
month = 12
It just looks ugly.
strptime()won't work for these.date-utilpackage too won't work for it. I'm parsing day with simple regexp and now I need to parse month somehow. The next string just takes parsed month and day and creates datetime object.'январь', and'January, 23'would be'23 января', so this just won't work.%Brefers only to the month, and will deal with russian dates if you set your locale correctly.