Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #207154

Re: date(1) in stretch and buster

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups linux.debian.user
Subject Re: date(1) in stretch and buster
Date 2019-04-08 21:30 +0200
Message-ID <xKI7U-2or-13@gated-at.bofh.it> (permalink)
References <xKEnD-8qa-1@gated-at.bofh.it> <xKG65-183-5@gated-at.bofh.it> <xKGfM-1bv-1@gated-at.bofh.it> <xKH2a-1IW-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


I managed to build a locale with a customized LC_TIME setting under
buster.  It's not documented in a straightforward manner anywhere I
could find, so I'm going to spell it all out here.


Step 1: Start with an existing locale definition.

In my case, I am starting with Debian buster's en_US locale, and I am
only going to change one of the variables in the LC_TIME section.


Step 2: Create some directories.

mkdir -p ~/.locale/src

The ~/.locale directory is where the custom locale is going to end up when
it's all done.  In addition to that, you need a temporary working directory
where the locale definition (source) files are going to live.  In my case,
I chose to make this a permanent home rather than a temporary directory.


Step 3: Copy the existing locale definition to the work directory.

cp /usr/share/i18n/locales/en_US ~/.locale/src/

This is a text file that defines the locale's behavior.  You can edit it
with any standard text editor.  You might want to take a moment to look
through it and figure out how it's laid out.  It's pretty straightforward.


Step 4: Modify the locale definition file.

In my case, I wanted to change the date_fmt variable inside the LC_TIME
section.  So first, I logged into a stretch box and found what it was
using:

stretch:~$ locale -k LC_TIME | grep date_fmt
date_fmt="%a %b %e %H:%M:%S %Z %Y"

Next, I edited the ~/.locale/src/en_US file and replaced the date_fmt line.

BEFORE:

% Appropriate date and time representation for date(1)
date_fmt "%a %d %b %Y %r %Z"

AFTER:

% Appropriate date and time representation for date(1)
date_fmt "%a %b %e %H:%M:%S %Z %Y"


Step 5: Compile the locale.

I18NPATH=~/.locale/src/ localedef -f UTF-8 -i en_US ~/.locale/en_US.UTF-8

This creates the directory ~/.locale/en_US.UTF-8 containing several binary
files.  This is what the C library uses.


Step 6: Test it.

buster:~$ date
Mon 08 Apr 2019 02:52:34 PM EDT
buster:~$ LOCPATH=~/.locale date
Mon Apr  8 14:52:38 EDT 2019


Step 7: Set environment variables to make this your new locale upon login.

All you need (assuming you use bash) is:

export LOCPATH="$HOME/.locale"

This will be either really easy, or really hard, depending on how you
login and what kind of Desktop Environment (if any) you use.  Suggested
reading:

https://mywiki.wooledge.org/DotFiles
https://wiki.debian.org/Xsession

In particular, it would be great to hear from anyone who manages to get
this working under GNOME, which is notorious for not allowing easy
customizations of the login environment.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

date(1) in stretch and buster Reco <recoverym4n@enotuniq.net> - 2019-04-08 17:30 +0200
  Re: date(1) in stretch and buster Étienne Mollier <etienne.mollier@mailoo.org> - 2019-04-08 19:20 +0200
    Re: date(1) in stretch and buster Cindy Sue Causey <butterflybytes@gmail.com> - 2019-04-08 19:30 +0200
      Re: date(1) in stretch and buster "Thomas Schmitt" <scdbackup@gmx.net> - 2019-04-08 19:50 +0200
      Re: date(1) in stretch and buster Étienne Mollier <etienne.mollier@mailoo.org> - 2019-04-08 20:20 +0200
        Re: date(1) in stretch and buster Greg Wooledge <wooledg@eeg.ccf.org> - 2019-04-08 21:30 +0200
    Re: date(1) in stretch and buster Reco <recoverym4n@enotuniq.net> - 2019-04-08 20:10 +0200
  Re: date(1) in stretch and buster Vincent Lefevre <vincent@vinc17.net> - 2019-04-09 15:50 +0200
    Re: date(1) in stretch and buster Gene Heskett <gheskett@shentel.net> - 2019-04-09 20:10 +0200
      Re: date(1) in stretch and buster Greg Wooledge <wooledg@eeg.ccf.org> - 2019-04-09 20:10 +0200
      Re: date(1) in stretch and buster Michael Stone <mstone@debian.org> - 2019-04-09 20:30 +0200
        Re: date(1) in stretch and buster Michael Stone <mstone@debian.org> - 2019-04-09 21:20 +0200
        Re: date(1) in stretch and buster Gene Heskett <gheskett@shentel.net> - 2019-04-09 21:20 +0200
      Re: date(1) in stretch and buster Étienne Mollier <etienne.mollier@mailoo.org> - 2019-04-09 20:40 +0200
        Re: date(1) in stretch and buster Curt <curty@free.fr> - 2019-04-09 22:10 +0200
          Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-09 23:00 +0200
      Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-09 20:40 +0200
        Re: date(1) in stretch and buster Étienne Mollier <etienne.mollier@mailoo.org> - 2019-04-09 20:50 +0200
          Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-09 21:50 +0200
        Re: date(1) in stretch and buster Gene Heskett <gheskett@shentel.net> - 2019-04-09 21:40 +0200
    Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-09 20:30 +0200
      Re: date(1) in stretch and buster Greg Wooledge <wooledg@eeg.ccf.org> - 2019-04-09 21:00 +0200
        Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-09 22:00 +0200
      Re: date(1) in stretch and buster Vincent Lefevre <vincent@vinc17.net> - 2019-04-10 13:40 +0200
        Re: date(1) in stretch and buster David Wright <deblis@lionunicorn.co.uk> - 2019-04-10 18:00 +0200

csiph-web