Localized strftime()

Sebastjan Trepca trepca at gmail.com
Sun Oct 23 22:03:10 CEST 2005


Great, it works, thanks :)

On 23/10/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Sebastjan Trepca wrote:
>
> > I'm trying to get a localized date format from strftime() but it seems
> > that is doesn't have any parameters for that or any information about
> > this issue in Python docs.
> >
> > For example I want to turn this:
> > 19 Oct, 2005
> > to this(slovene language):
> > 19 Okt, 2005
>
> you must call locale.setlocale first, to switch from the default C
> locale to a locale of your choice.
>
>     http://docs.python.org/lib/module-locale.html
>
> >>> import time
> >>> print time.strftime("%a, %d %b %Y %H:%M:%S")
> Sun, 23 Oct 2005 20:38:56
> >>> import locale
> >>> locale.setlocale(locale.LC_TIME, "sv_SE") # swedish
> 'sv_SE'
> >>> print time.strftime("%a, %d %b %Y %H:%M:%S")
> sön, 23 okt 2005 20:39:15
> >>> locale.setlocale(locale.LC_TIME, "sl_SI")
> 'sl_SI'
> >>> print time.strftime("%a, %d %b %Y %H:%M:%S")
> ned, 23 okt 2005 20:39:32
>
> </F>
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list