Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Show me locale fomats

10 views
Skip to first unread message

Dotan Cohen

unread,
Jun 23, 2009, 10:40:07 AM6/23/09
to
On a Debian system how can the user see what his locale configuration
configures? For instance, I know that if a user has:
LC_TIME="en_US.UTF-8"
then his date format is mm/dd/yyyy however where can I see that? How
can I get the system to show that to me?

Thanks!

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Ólafur Jens Sigurðsson

unread,
Jun 23, 2009, 10:50:33 AM6/23/09
to
On Tue, Jun 23, 2009 at 05:34:08PM +0300, Dotan Cohen wrote:
> On a Debian system how can the user see what his locale configuration
> configures? For instance, I know that if a user has:
> LC_TIME="en_US.UTF-8"
> then his date format is mm/dd/yyyy however where can I see that? How
> can I get the system to show that to me?
>

by issuing the locale command.

Cheers

Oli

Dotan Cohen

unread,
Jun 23, 2009, 12:00:22 PM6/23/09
to
> by issuing the locale command.
>

I mean, let's say that I want yyyy-mm-dd date format? What command can
I give to show me which locale I must configure to get that format?

Sorry for not asking a clear question.

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il


Roger Leigh

unread,
Jun 23, 2009, 12:20:12 PM6/23/09
to
On Tue, Jun 23, 2009 at 06:54:34PM +0300, Dotan Cohen wrote:
> > by issuing the locale command.
> >
>
> I mean, let's say that I want yyyy-mm-dd date format? What command can
> I give to show me which locale I must configure to get that format?

Normally you don't need to know. You use strptime(3) to print the
date and/or time. For example, strptime("%c", ...). The manual
page will give you the detail.

To get the format string, do:
locale -k d_fmt
d_fmt="%d/%m/%y"
(en_GB)

A list of keywords is found in locale(5).

(I don't know how to get this from within a program using a C
library interface. Does anyone else have any ideas?)


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.

Dotan Cohen

unread,
Jun 23, 2009, 12:30:14 PM6/23/09
to
> Normally you don't need to know.  You use strptime(3) to print the
> date and/or time.  For example, strptime("%c", ...).  The manual
> page will give you the detail.
>
> To get the format string, do:
> locale -k d_fmt
> d_fmt="%d/%m/%y"
> (en_GB)
>
> A list of keywords is found in locale(5).
>

I see, thanks. Other than changing my locale to a foreign locale
(well, ok, US is a foreign locale for me but there is a reason that I
keep it), is there a way to configure yyyy-mm-dd date format?

Thanks!

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il


Roger Leigh

unread,
Jun 23, 2009, 12:30:14 PM6/23/09
to
On Tue, Jun 23, 2009 at 05:17:31PM +0100, Roger Leigh wrote:
> On Tue, Jun 23, 2009 at 06:54:34PM +0300, Dotan Cohen wrote:
> > > by issuing the locale command.
> > >
> >
> > I mean, let's say that I want yyyy-mm-dd date format? What command can
> > I give to show me which locale I must configure to get that format?
>
> Normally you don't need to know. You use strptime(3) to print the
> date and/or time. For example, strptime("%c", ...). The manual
> page will give you the detail.
>
> To get the format string, do:
> locale -k d_fmt
> d_fmt="%d/%m/%y"
> (en_GB)
>
> A list of keywords is found in locale(5).
>
> (I don't know how to get this from within a program using a C
> library interface. Does anyone else have any ideas?)

Appears to be just calling nl_langinfo(3).

Roger Leigh

unread,
Jun 23, 2009, 1:00:12 PM6/23/09
to
On Tue, Jun 23, 2009 at 07:24:54PM +0300, Dotan Cohen wrote:
> > Normally you don't need to know. �You use strptime(3) to print the
> > date and/or time. �For example, strptime("%c", ...). �The manual
> > page will give you the detail.
> >
> > To get the format string, do:
> > locale -k d_fmt
> > d_fmt="%d/%m/%y"
> > (en_GB)
> >
> > A list of keywords is found in locale(5).
> >
>
> I see, thanks. Other than changing my locale to a foreign locale
> (well, ok, US is a foreign locale for me but there is a reason that I
> keep it), is there a way to configure yyyy-mm-dd date format?

Well, it depends on what you want to do. If you're using a desktop
environment like KDE, they may offer a way to customise this for just
you. However, this will only affect KDE applications which use this
configuration.

You can generate a custom locale. So instead of en_GB.UTF-8, I could
create en...@custdate.UTF-8. Do do this, you'll need to look at the
locales package and localedef. This will be available system-wide.
Once you have generated your custom locale, you can just choose it
like any other either with the LANG/LC_* environment variables or
in the desktop environment.

Note that if you only want to customise the date for the locale, just
set LC_TIME=en_GB or whatever you like. The rest of the locale will
remain the same; only date/time formatting is changed.


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.

Florian Kulzer

unread,
Jun 23, 2009, 6:10:14 PM6/23/09
to
On Tue, Jun 23, 2009 at 17:52:01 +0100, Roger Leigh wrote:
> On Tue, Jun 23, 2009 at 07:24:54PM +0300, Dotan Cohen wrote:

[...]

> > I see, thanks. Other than changing my locale to a foreign locale
> > (well, ok, US is a foreign locale for me but there is a reason that I
> > keep it), is there a way to configure yyyy-mm-dd date format?

[...]

> Note that if you only want to customise the date for the locale, just
> set LC_TIME=en_GB or whatever you like. The rest of the locale will
> remain the same; only date/time formatting is changed.

To find out which locales on your system have the yyyy-mm-dd date
format, run:

grep ^d_fmt /usr/share/i18n/locales/* | ascii2uni -qaA | grep '%Y-%m-%d'

(ascii2uni is part of the uni2ascii package)

--
Regards, | http://users.icfo.es/Florian.Kulzer
Florian |

Kelly Clowers

unread,
Jun 23, 2009, 8:10:09 PM6/23/09
to
2009/6/23 Dotan Cohen <dotan...@gmail.com>:

>> Normally you don't need to know.  You use strptime(3) to print the
>> date and/or time.  For example, strptime("%c", ...).  The manual
>> page will give you the detail.
>>
>> To get the format string, do:
>> locale -k d_fmt
>> d_fmt="%d/%m/%y"
>> (en_GB)
>>
>> A list of keywords is found in locale(5).
>>
>
> I see, thanks. Other than changing my locale to a foreign locale
> (well, ok, US is a foreign locale for me but there is a reason that I
> keep it), is there a way to configure yyyy-mm-dd date format?


Set English in Denmark (en_DK.UTF-8) as your LC_TIME.
Obviously something like jp_JP would also do it, but then
you would get Japanese month names, etc.


Cheers,
Kelly Clowers

Osamu Aoki

unread,
Jun 24, 2009, 8:50:14 AM6/24/09
to
On Tue, Jun 23, 2009 at 05:34:08PM +0300, Dotan Cohen wrote:
> On a Debian system how can the user see what his locale configuration
> configures? For instance, I know that if a user has:
> LC_TIME="en_US.UTF-8"
> then his date format is mm/dd/yyyy however where can I see that? How
> can I get the system to show that to me?

Please read:
http://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_customized_display_of_time_and_date
http://www.debian.org/doc/manuals/debian-reference/ch01.en.html#_lang_variable
http://www.debian.org/doc/manuals/debian-reference/ch08.en.html

Good luck,

Osamu

Dotan Cohen

unread,
Jun 24, 2009, 11:10:12 AM6/24/09
to
2009/6/24 Osamu Aoki <os...@debian.org>:

> On Tue, Jun 23, 2009 at 05:34:08PM +0300, Dotan Cohen wrote:
>> On a Debian system how can the user see what his locale configuration
>> configures? For instance, I know that if a user has:
>> LC_TIME="en_US.UTF-8"
>> then his date format is mm/dd/yyyy however where can I see that? How
>> can I get the system to show that to me?
>
> Please read:
>  http://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_customized_display_of_time_and_date
>  http://www.debian.org/doc/manuals/debian-reference/ch01.en.html#_lang_variable
>  http://www.debian.org/doc/manuals/debian-reference/ch08.en.html
>

Thank you, Osamu. While I am one of the few people who actually
appreciate being RTFMed, in this case the fine manual jsut did not
state what I needed. I will admit, however, that I do spend more time
googling nowadays rather than going right to the manual.

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il


0 new messages