strptime gives "unconverted data remains" for non en_US locale
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
notify-python (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
This code:
#!/usr/bin/env python
import pynotify
import time
import datetime
c='5/1/12 1:15 PM'
print c
dt = time.strptime(c, "%d/%m/%y %H:%M %p")
produces:
5/1/12 1:15 PM
Traceback (most recent call last):
File "tmp.py", line 9, in <module>
dt = time.strptime(c, "%d/%m/%y %H:%M %p")
File "/usr/lib/
return _strptime(
File "/usr/lib/
data_
ValueError: unconverted data remains: PM
Removing the import pynotify,
#!/usr/bin/env python
import time
import datetime
c='5/1/12 1:15 PM'
print c
dt = time.strptime(c, "%d/%m/%y %H:%M %p")
causes no error.
It appears to be as a result of a non en_US locale. My locale is currently set to nb_NO.UTF-8. Setting this to en_US.UTF-8 fixes the issue.
See this address for pretty printed code. http:// stackoverflow. com/questions/ 10402304/ pynotify- screws- up-datetime- why