-1

I've been trying to change the default date format since past few days.

Current format:-

$date
Mon Aug 20 14:14:43 IST 2018

Expected format:-

$date
Monday August 20 14:14:43 IST 2018

Current locale

$locale

LANG=en_IN
LANGUAGE=
LC_CTYPE=en_IN
LC_NUMERIC="en_IN"
LC_TIME=en_DK
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=

LC_TIME section in /usr/share/i18n/locales/en_DK

% 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  ""

% 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>"

I have referred this tutorial which I have come across to be the best and lengthy enough to be clear.

I'm using Ubuntu 16.04 stretch. I need to modify this en_DK file or create a custom locale that suits my need. Although there are several workarounds like creating aliases. But I prefer to know what is going wrong.

Melebius
  • 11,431
  • 9
  • 52
  • 78
Gowtham
  • 311
  • Do you ask how to create a custom locale? In that case it's a duplicate of for instance https://askubuntu.com/questions/21316/how-can-i-customize-a-system-locale – Gunnar Hjalmarsson Aug 20 '18 at 10:28
  • No.. It is not about creating custom locale.. But, I Need to modify the existing locale and recompile it with LC_TIME section changes... – Gowtham Aug 20 '18 at 11:01

1 Answers1

1

I would really recommend to use

date +'%A %B %e %H:%M:%S %Z %Y'

instead somehow. Creating a custom locale for the purpose feels like overdoing it.

Edit:

An option might be to

  • edit date_fmt in the en_DK locale definition file and replace <U0061> and <U0062> with <U0041> respective <U0042>
  • run the command sudo locale-gen en_DK.UTF-8

You should also set en_DK.UTF_8 for LC_TIME, not en_DK (the latter enables latin1 encoding).

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94