I need to write a very simple python function which accepts a date in Excel format (an integer of days elapsed since 1st Jan 1900). I convert that to a python datetime.date object, and finally I'd like to format that as a shortened string date (e.g. "Jan10" or "Mar11") - basically the date in MmmYY format.
dt.strftime( fmt )
This function works just fine on UK & US workstations, however I've noticed that on some colleagues PCs which are set to a French locale we get the wrong anser:
>>> locale.getdefaultlocale()
('fr_FR', 'cp1252')
On these machines the function above returns the formatted date-string in French which is not the desired output.
I understand that I could use the locale.setlocale function to globally re-define the locale, however this is not something which is desirable. Elsewhere in the system there is likely to be scripts which require a native-language locale. I do not wish to break somebody else's component by re-defining a global locale.
So what can I do? Short of re-writing the string-formatting function, is there a way I can make the strftime function produce it's output in the UK/US locale without affecting anything else?
Platform = Python2.4.4 on Windows 32bit
FYI, this solution does not apply - it changes the locale globally which is exactly what I want to avoid doing: Locale date formatting in Python