Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Lc_time yyyy-mm-dd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Chopstix
n00b
n00b


Joined: 20 Oct 2012
Posts: 20

PostPosted: Tue Dec 03, 2013 10:28 pm    Post subject: Lc_time yyyy-mm-dd Reply with quote

Hi

I am trying to get dates to be displayed in the format YYYY-MM-DD and this is proving ridiculously difficult.

From the beginning.
I had LC_ALL=en_US.utf8 and this resulted in:
$ eix x11-drivers/xf86-video-nouveau | grep 13:
Installed versions:  1.0.10(06:43:52 PM 12/03/2013)

??/??/YYYY looks ridiculous, and furthermore I read that LC_ALL is a bad idea because you can't overwrite any of the individual items, so I changed it.

By the way, long-iso prints dates the way I want them, but I guess I can't use that in the locale.
$ ls -l:

total 16
drwxr-xr-x 2 portage portage 4096 Dec  3 18:45 hsperfdata_portage
drwxr-xr-x 2 root    root    4096 Dec  3 13:54 hsperfdata_root
drwx------ 2 kdm     kdm     4096 Dec  3 10:04 kde-kdm
drwx------ 2 kdm     kdm     4096 Dec  3 10:04 ksocket-kdm
$ TIME_STYLE="long-iso" ls -l
total 16
drwxr-xr-x 2 portage portage 4096 2013-12-03 18:45 hsperfdata_portage
drwxr-xr-x 2 root    root    4096 2013-12-03 13:54 hsperfdata_root
drwx------ 2 kdm     kdm     4096 2013-12-03 10:04 kde-kdm
drwx------ 2 kdm     kdm     4096 2013-12-03 10:04 ksocket-kdm


long-iso isn't in /usr/share/i18n/locales/, but POSIX is, so I tried adding that to /etc/locale.gen
# cat /etc/locale.gen:

# /etc/locale.gen: list all of the locales you want to have on your system
#
# The format of each line:
# <locale> <charmap>
#
# Where <locale> is a locale located in /usr/share/i18n/locales/ and
# where <charmap> is a charmap located in /usr/share/i18n/charmaps/.
#
# All blank lines and lines starting with # are ignored.
#
# For the default list of supported combinations, see the file:
# /usr/share/i18n/SUPPORTED
#
# Whenever glibc is emerged, the locales listed here will be automatically
# rebuilt for you.  After updating this file, you can simply run `locale-gen`
# yourself instead of re-emerging glibc.

#en_US ISO-8859-1
#en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
#ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
#de_DE ISO-8859-1
#de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1

en_US UTF-8
POSIX UTF-8

and then execute locale-gen
# locale-gen:

 * Generating 2 locales (this might take a while) with 1 jobs
 *  (1/2) Generating en_US.UTF-8 ... [ ok ]
 *  (2/2) Generating POSIX.UTF-8 ...LC_MONETARY: value of field `int_curr_symbol' has wrong length
No definition for LC_PAPER category found
No definition for LC_NAME category found
No definition for LC_ADDRESS category found
No definition for LC_TELEPHONE category found
No definition for LC_MEASUREMENT category found
No definition for LC_IDENTIFICATION category found
 [ !! ]
 * Generation complete


Now I eselect it:
# eselect locale list:

Available targets for the LANG variable:
  [1]   C
  [2]   POSIX
  [3]   POSIX.utf8 *
  [4]   en_US
  [5]   en_US.utf8
  [ ]   (free form)

# eselect locale set 5:

Setting LANG to en_US.utf8 ...
Run ". /etc/profile" to update the variable in your shell.

# . /etc/profile:

-su: warning: setlocale: LC_TIME: cannot change locale (POSIX.UTF-8)


# cat /etc/env.d/02locale:

# Configuration file for eselect
# This file has been automatically generated.
LANG="en_US.utf8"
LC_TIME="POSIX.UTF-8"

# . /etc/profile:

-su: warning: setlocale: LC_TIME: cannot change locale (POSIX.UTF-8)


$ eix x11-drivers/xf86-video-nouveau | grep 13:
Installed versions:  1.0.10(06:43:52 PM 12/03/2013)


ლ(ձ_ճლ) y u no work?

I see I'm not the only one frustrated by this. See Miernik's posts, my thoughts exactly:
Miernik http://www.linux-archive.org/gentoo-user/127817-warning-locale-not-supported-xlib-locale-set-c.html wrote:

Anyway, why is this we have to choose a territory for our language, I do
not live in any english-speaking territory, nor it is Denmark, and I
don't want to put on my computer on what territory I live, as it is none
of it's business. Couldn't there be something like POSIX.UTF-8 locale,
or maybe make the POSIX locale be UTF-8 by default? Or C.UTF-8
I would be very happy not having to put any specific country in the
settings of my computer.

And ordering of date - what does that have to do with territory and
language? I don't care what territory has what ordering commonly used -
I want to have it in form 2008-07-19, is there a way to do it?
(...)
Because how I like my computer to communicate with me, has nothing to do
with the territory on which it is located, the computer moved across
different territories, my computers are often on different territories
that I am, none of the territories the computer or I are frequently
located speak the language I want my computer to communicate in, nor do
their standard of dates are how I like then to be - I choose them to be
based on reason (dates shown from largest unit to smallest), not on
tradition or politics. I feel a world citizen, and don't want to be
psychologically tied to any single country, nor my computers, I feel its
horribly stupid to configure computers based on territory, its an
unneeded breach of privacy in case someone looks over my shoulder as I
type "locale" and sees a territory, then he/she would think I might have
ties to that territory, like if its the police or something, if I put
en_US than someone might think I am an US person, while I am not, and I
don't want to spend my time wondering which territory I should put in
when installing Linux, US, or GB or whatever, I just want a damn simple
international english territory neutral locale with dates in the form
YYYY-MM-DD and 24-hour clock time and . as the decimal separator (not ,
as it is in the en_DK locale). Is that so difficult to do?
(...)
How can I tell to LC_TIME that I want dates in yyyy-mm-dd format, and
24-hour clock time, and if anything wants week or month name, then show
it in english?
Back to top
View user's profile Send private message
fturco
Apprentice
Apprentice


Joined: 08 Dec 2010
Posts: 240
Location: Italy

PostPosted: Wed Dec 04, 2013 11:38 am    Post subject: Reply with quote

I don't think POSIX.UTF-8 is a valid locale. You can use instead a locale with the ISO date format, such as en_DK.UTF-8. Also, be sure to read the localization guide and the UTF-8 guide on the wiki.
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1122

PostPosted: Wed Dec 04, 2013 12:57 pm    Post subject: Reply with quote

Ignore LC_ALL - don't set it, because:
Quote:
LC_ALL A special variable for overriding all other settings.

Set all of the other LC_* to plain en_US.utf8 but LC_TIME to your special needs!
As a german I don't like special german sort ordering but posix: LC_COLLATE=C
Using systemd symlink to /etc/locale.conf

PS: I never got it why there are two formats:
en_US.utf8
en_US.UTF-8
_________________
fun2gen2
Back to top
View user's profile Send private message
Chopstix
n00b
n00b


Joined: 20 Oct 2012
Posts: 20

PostPosted: Wed Dec 04, 2013 4:06 pm    Post subject: Reply with quote

fturco: POSIX is a valid locale, UTF8 is a valid charmap.
As Miernik wrote, I don't want to use Denmark. I'm not Danish, I don't speak Danish save for a few swearwords, I can't tell Monday from Tuesday in Danish, I think it's a flat and expensive country, I don't want to use Denmark.
I did read the localization guide, as should be evident by what I wrote.

ulenrich: I already ceased using LC_ALL.
I don't use systemd.
I can't set LC_TIME "to my special needs" (which are surely not so special) because I don't know how to, that's why I came here.

en_US:
LC_TIME
abday   "<U0053><U0075><U006E>";"<U004D><U006F><U006E>";/
   "<U0054><U0075><U0065>";"<U0057><U0065><U0064>";/
   "<U0054><U0068><U0075>";"<U0046><U0072><U0069>";/
   "<U0053><U0061><U0074>"
day   "<U0053><U0075><U006E><U0064><U0061><U0079>";/
   "<U004D><U006F><U006E><U0064><U0061><U0079>";/
   "<U0054><U0075><U0065><U0073><U0064><U0061><U0079>";/
   "<U0057><U0065><U0064><U006E><U0065><U0073><U0064><U0061><U0079>";/
   "<U0054><U0068><U0075><U0072><U0073><U0064><U0061><U0079>";/
   "<U0046><U0072><U0069><U0064><U0061><U0079>";/
   "<U0053><U0061><U0074><U0075><U0072><U0064><U0061><U0079>"

week    7;19971130;7
first_weekday   1
first_workday   2
abmon   "<U004A><U0061><U006E>";"<U0046><U0065><U0062>";/
   "<U004D><U0061><U0072>";"<U0041><U0070><U0072>";/
   "<U004D><U0061><U0079>";"<U004A><U0075><U006E>";/
   "<U004A><U0075><U006C>";"<U0041><U0075><U0067>";/
   "<U0053><U0065><U0070>";"<U004F><U0063><U0074>";/
   "<U004E><U006F><U0076>";"<U0044><U0065><U0063>"
mon   "<U004A><U0061><U006E><U0075><U0061><U0072><U0079>";/
   "<U0046><U0065><U0062><U0072><U0075><U0061><U0072><U0079>";/
   "<U004D><U0061><U0072><U0063><U0068>";/
   "<U0041><U0070><U0072><U0069><U006C>";/
   "<U004D><U0061><U0079>";/
   "<U004A><U0075><U006E><U0065>";/
   "<U004A><U0075><U006C><U0079>";/
   "<U0041><U0075><U0067><U0075><U0073><U0074>";/
   "<U0053><U0065><U0070><U0074><U0065><U006D><U0062><U0065><U0072>";/
   "<U004F><U0063><U0074><U006F><U0062><U0065><U0072>";/
   "<U004E><U006F><U0076><U0065><U006D><U0062><U0065><U0072>";/
   "<U0044><U0065><U0063><U0065><U006D><U0062><U0065><U0072>"
% Appropriate date and time representation (%c)
%   "%a %d %b %Y %r %Z"
d_t_fmt "<U0025><U0061><U0020><U0025><U0064><U0020><U0025><U0062><U0020><U0025><U0059><U0020><U0025><U0072><U0020><U0025><U005A>"
%
% Appropriate date representation (%x)
%   "%m/%d/%Y"
d_fmt   "<U0025><U006D><U002F><U0025><U0064><U002F><U0025><U0059>"
%
% Appropriate time representation (%X)
%   "%r"
t_fmt   "<U0025><U0072>"
%
% Appropriate AM/PM time representation (%r)
%   "%I:%M:%S %p"
t_fmt_ampm "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/
<U0025><U0070>"
%
% Strings for AM/PM
%
am_pm   "<U0041><U004D>";"<U0050><U004D>"
%
% Appropriate date representation (date(1))   "%a %b %e %H:%M:%S %Z %Y"
date_fmt   "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065>/
<U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/
<U0025><U005A><U0020><U0025><U0059>"
END LC_TIME

en_DK:
LC_TIME
abday    "<U0053><U0075><U006E>";"<U004D><U006F><U006E>";/
    "<U0054><U0075><U0065>";"<U0057><U0065><U0064>";/
    "<U0054><U0068><U0075>";"<U0046><U0072><U0069>";/
    "<U0053><U0061><U0074>"
day      "<U0053><U0075><U006E><U0064><U0061><U0079>";/
    "<U004D><U006F><U006E><U0064><U0061><U0079>";/
    "<U0054><U0075><U0065><U0073><U0064><U0061><U0079>";/
    "<U0057><U0065><U0064><U006E><U0065><U0073><U0064><U0061><U0079>";/
    "<U0054><U0068><U0075><U0072><U0073><U0064><U0061><U0079>";/
    "<U0046><U0072><U0069><U0064><U0061><U0079>";/
    "<U0053><U0061><U0074><U0075><U0072><U0064><U0061><U0079>"
abmon    "<U004A><U0061><U006E>";"<U0046><U0065><U0062>";/
    "<U004D><U0061><U0072>";"<U0041><U0070><U0072>";/
    "<U004D><U0061><U0079>";"<U004A><U0075><U006E>";/
    "<U004A><U0075><U006C>";"<U0041><U0075><U0067>";/
    "<U0053><U0065><U0070>";"<U004F><U0063><U0074>";/
    "<U004E><U006F><U0076>";"<U0044><U0065><U0063>"
mon      "<U004A><U0061><U006E><U0075><U0061><U0072><U0079>";/
    "<U0046><U0065><U0062><U0072><U0075><U0061><U0072><U0079>";/
    "<U004D><U0061><U0072><U0063><U0068>";/
    "<U0041><U0070><U0072><U0069><U006C>";/
    "<U004D><U0061><U0079>";/
    "<U004A><U0075><U006E><U0065>";/
    "<U004A><U0075><U006C><U0079>";/
    "<U0041><U0075><U0067><U0075><U0073><U0074>";/
    "<U0053><U0065><U0070><U0074><U0065><U006D><U0062><U0065><U0072>";/
    "<U004F><U0063><U0074><U006F><U0062><U0065><U0072>";/
    "<U004E><U006F><U0076><U0065><U006D><U0062><U0065><U0072>";/
    "<U0044><U0065><U0063><U0065><U006D><U0062><U0065><U0072>"
% date formats following ISO 8601-1988
d_t_fmt  "<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064><U0054><U0025><U0054><U0020><U0025><U005A>"
d_fmt    "<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064>"
t_fmt    "<U0025><U0054>"
am_pm    "";""
t_fmt_ampm  ""
date_fmt   "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065>/
<U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/
<U0025><U005A><U0020><U0025><U0059>"
week    7;19971130;4
first_weekday 2
first_workday 2
END LC_TIME

POSIX:
LC_TIME
# This is the POSIX Locale definition for
# the LC_TIME category.
#
# Abbreviated weekday names (%s)
abday   "<U0053><U0075><U006E>";"<U004D><U006F><U006E>";\
        "<U0054><U0075><U0065>";"<U0057><U0065><U0064>";\
        "<U0054><U0068><U0075>";"<U0046><U0072><U0069>";\
        "<U0053><U0061><U0074>"
#
# Full weekday names (%A)
day     "<U0053><U0075><U006E><U0064><U0061><U0079>";\
        "<U004D><U006F><U006E><U0064><U0061><U0079>";\
        "<U0054><U0075><U0065><U0073><U0064><U0061><U0079>";\
        "<U0057><U0065><U0064><U006E><U0065><U0073><U0064><U0061><U0079>";\
        "<U0054><U0068><U0075><U0072><U0073><U0064><U0061><U0079>";\
        "<U0046><U0072><U0069><U0064><U0061><U0079>";\
        "<U0053><U0061><U0074><U0075><U0072><U0064><U0061><U0079>"
#
# Abbreviated month names (%b)
abmon   "<U004A><U0061><U006E>";"<U0046><U0065><U0062>";\
        "<U004D><U0061><U0072>";"<U0041><U0070><U0072>";\
        "<U004D><U0061><U0079>";"<U004A><U0075><U006E>";\
        "<U004A><U0075><U006C>";"<U0041><U0075><U0067>";\
        "<U0053><U0065><U0070>";"<U004F><U0063><U0074>";\
        "<U004E><U006F><U0076>";"<U0044><U0065><U0063>"
#
# Full month names (%B)
mon     "<U004A><U0061><U006E><U0075><U0061><U0072><U0079>";\
        "<U0046><U0065><U0062><U0072><U0075><U0061><U0072><U0079>";\
        "<U004D><U0061><U0072><U0063><U0068>";\
        "<U0041><U0070><U0072><U0069><U006C>";\
        "<U004D><U0061><U0079>";\
        "<U004A><U0075><U006E><U0065>";\
        "<U004A><U0075><U006C><U0079>";\
        "<U0041><U0075><U0067><U0075><U0073><U0074>";\
        "<U0053><U0065><U0070><U0074><U0065><U006D><U0062><U0065><U0072>";\
        "<U004F><U0063><U0074><U006F><U0062><U0065><U0072>";\
        "<U004E><U006F><U0076><U0065><U006D><U0062><U0065><U0072>";\
        "<U0044><U0065><U0063><U0065><U006D><U0062><U0065><U0072>"
#
# Equivalent of AM/PM (%p)      "AM"/"PM"
am_pm   "<U0041><U004D>";"<U0050><U004D>"
#
# Appropriate date and time representation (%c)
#       "%a %b %e %H:%M:%S %Y"
d_t_fmt "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065>\
<U0020><U0025><U0048><U003A><U0025><U004D>\
<U003A><U0025><U0053><U0020><U0025><U0059>"
#
# Appropriate date representation (%x)   "%m/%d/%y"
d_fmt   "<U0025><U006D><U002F><U0025><U0064><U002F><U0025><U0079>"
#
# Appropriate time representation (%X)   "%H:%M:%S"
t_fmt   "<U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053>"
#
# Appropriate 12 h time representation (%r)   "%I:%M:%S %p"
t_fmt_ampm "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053>\
<U0020><U0025><U0070>"
#
# Appropriate date representation (date(1))   "%a %b %e %H:%M:%S %Z %Y"
date_fmt   "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065><U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0025><U005A><U0020><U0025><U0059>"
END LC_TIME
Back to top
View user's profile Send private message
Fitzcarraldo
Guru
Guru


Joined: 30 Aug 2008
Posts: 464
Location: United Kingdom

PostPosted: Wed Dec 04, 2013 7:02 pm    Post subject: Reply with quote

Not that I have tried it, but How can I customize a system locale? looks like it might be of use. It tells you how to modify an existing locale and how to create a locale from scratch.
_________________
Fitzcarraldo's blog
Back to top
View user's profile Send private message
wuzzerd
Guru
Guru


Joined: 05 Jan 2005
Posts: 430
Location: New Mexico

PostPosted: Wed Dec 04, 2013 7:36 pm    Post subject: Reply with quote

This may not be the absolute correct way to do this, what am I to know, in /etc/env.d/02locale I added the line
Code:
TIME_STYLE="long-iso"
then did
Code:
# env-update
# source /etc/profile


It has no effect upon eix, however.
Back to top
View user's profile Send private message
Fitzcarraldo
Guru
Guru


Joined: 30 Aug 2008
Posts: 464
Location: United Kingdom

PostPosted: Thu Dec 05, 2013 11:57 am    Post subject: Reply with quote

An easier-to-understand 'How To' than the one I posted earlier: How to change date formats on Ubuntu.

Note also a comment on 18 February 2013:

Sérgio Carvalho wrote:
Instead of looking up the ASCII table to generate the string, you can use hexdump to do it for you. Example:
Code:
echo -n %Y/%m/%d | hexdump -v -e '/1 "<U00%02X>"' ; echo

_________________
Fitzcarraldo's blog
Back to top
View user's profile Send private message
Chopstix
n00b
n00b


Joined: 20 Oct 2012
Posts: 20

PostPosted: Thu Dec 05, 2013 12:24 pm    Post subject: Reply with quote

Thank you, these links explain how to make a custom locale well.
Pity it's still such a PITA to do it.
Back to top
View user's profile Send private message
Fitzcarraldo
Guru
Guru


Joined: 30 Aug 2008
Posts: 464
Location: United Kingdom

PostPosted: Thu Dec 05, 2013 1:00 pm    Post subject: Reply with quote

Yes, it seems there is no easy way to do it; you have to hack and create a custom locale. Instead of using that command I quoted earlier, a good on-line tool for doing the same thing and more is: Unicode Code Converter, which I found referenced on another good 'How To': Locale: Customising and Making Your Own Date and Time.
_________________
Fitzcarraldo's blog
Back to top
View user's profile Send private message
seansmr
n00b
n00b


Joined: 04 Dec 2011
Posts: 23
Location: Bangkok

PostPosted: Tue Jan 14, 2014 9:40 am    Post subject: Can I Lunix be my primary OS if I can't set the date format Reply with quote

I have been trying to fix my date as well. I also prefer the date format YYYY-MM-DD. The dash leaves more white space and makes the numbers more readable than a slash. I don't care at all about what it is supposed to be for the country I am currently in.
Just to get it working, I have accepted using locales that I am not in. en.CA works for the date. But other locales will have to be used to get other things right, ie I am in an A4 country. What a silly way.

I think that it is not good that format work this way. You just want to set a date format your way and you end up having to use different locales for different locale LS_xxxx settings. Will using different locales for different settings cause any problems?

Creating a custom local just to get your date the way you want it! Editing a unicode file, non-human readable. No wonder more people don't use Linux.

I have been trying to see if I can use Linux as my primary OS. I can use it for a lot of things, but the last 20% is proving quite difficult.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum