Re: Localized strftime()

Discussion in 'Python' started by Fredrik Lundh, Oct 23, 2005.

  1. 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>
    Fredrik Lundh, Oct 23, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piotr Strycharz

    Customizing localized applications

    Piotr Strycharz, Aug 20, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    309
    clintonG
    Aug 20, 2004
  2. Jéjé
    Replies:
    0
    Views:
    482
    Jéjé
    Jun 25, 2005
  3. =?Utf-8?B?SGVua2U=?=

    Adding a control to a localized ASP .NET 2.0 application

    =?Utf-8?B?SGVua2U=?=, Aug 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    334
    =?Utf-8?B?SGVua2U=?=
    Aug 8, 2005
  4. Sebastjan Trepca

    Localized strftime()

    Sebastjan Trepca, Oct 23, 2005, in forum: Python
    Replies:
    0
    Views:
    293
    Sebastjan Trepca
    Oct 23, 2005
  5. Florian Munz

    No localized strings in Date.strftime

    Florian Munz, Mar 26, 2005, in forum: Ruby
    Replies:
    0
    Views:
    85
    Florian Munz
    Mar 26, 2005
Loading...

Share This Page