I am using datetime.strptime() to get the month number from a month, written in full english. I want to use this in combination with some PySide Qt intetrface. However, the month recognition seems to break as soon as I start a QApplication.
Minimum working example (i'm printing the locale to show that it doesn't change):
import sys, datetime
from PySide.QtCore import *
from PySide.QtGui import *
import locale
print(locale.getlocale())
full_date = 'February'
print(datetime.datetime.strptime(full_date,'%B'))
Output:
('en_US', 'UTF-8')
1900-02-01 00:00:00
Now when I start a QApplication and do the same:
import sys, datetime
from PySide.QtCore import *
from PySide.QtGui import *
import locale
qt_app = QApplication(sys.argv)
print(locale.getlocale())
full_date = 'February'
print(datetime.datetime.strptime(full_date,'%B'))
Output:
('en_US', 'UTF-8')
Traceback (most recent call last):
File "my_timedate.py", line 12, in <module>
print(datetime.datetime.strptime(full_date,'%B'))
File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
(data_string, format))
ValueError: time data 'February' does not match format '%B'
What is going on? Why does it stop working after starting the QApplication?