1833800 Members
2506 Online
110063 Solutions
New Discussion

LC_TIME values

 
SOLVED
Go to solution
HPCS France
Advisor

LC_TIME values

HP-UX 11.11
Hi,

i want customize the output of "ll" for have the day date on 2 digit.
i saw "ll" take the format by LC_TIME value, so, i tried to customize my locales but i don't know what i must modify in the locale source, i already made:

# cd /usr/lib/nls/loc/
# cp fr_FR.iso885915.src test.src
modify the paragraph LC_TIME
# localedef -v -c -i test.src test
# export LANG=test LC_ALL=test

i verified the new parameters by
# locale LC_TIME
"Dim";"Lun";"Mar";"Mer";"Jeu";"Ven";"Sam"
"Dimanche";"Lundi";"Mardi";"Mercredi";"Jeudi";"Vendredi";"Samedi"
"toto";"fevr";"mars";"avr";"mai";"juin";"juil";"aout";"sept";"oct";"nov";"dec"
"janvier";"fevrier";"mars";"avril";"mai";"juin";"juillet";"aout";"septembre";"octobre";"novembre";"decembre"
"%A %d %B %Y %H:%M:%S"
"%A %d %B %Y"
"%H:%M:%S"
"";""
"%H:%M:%S"
""
""
""
""
""
""
""
""
""
""

now, "ll" modify correctly the month, "Jan" is view as "toto" (it was for test) but the day of the date is already on 1 digit for the firsts month's days
i have:
dr-xr-xr-x 13 bin bin 4096 tato 5 12:00 /var/sam
i want:
dr-xr-xr-x 13 bin bin 4096 tato 05 12:00 /var/sam

i think i must add another parameter but i don't know what.

is there somebody for help please?
8 REPLIES 8
Keith Bryson
Honored Contributor

Re: LC_TIME values

Hi there

Under the LC_TIME section in the src file, there are 2 lines that correspond to date format (d_fmt d_t_fmt) and they contain the text:

........ ........

the reference to (in the middle of this line) is equivalent to 'date +%.1d' (try it). To get around your problem, try REMOVING the text so the line becomes something like:

........
........

Let us know how you get on

All the best - Keith
Arse-cover at all costs
HPCS France
Advisor

Re: LC_TIME values

Hi,

i already try that as you can see above (the result of "locale LC_TIME"), but "ll" does not appear to use this field.

thanks
Keith Bryson
Honored Contributor

Re: LC_TIME values

OK - I see what you are saying now.

I have %e in my locale which is understandable as the day is expressed as " 1" -> "31" (ie. single dates are padded with spaces rather than 0).

Can you specify 2d rather than just d? That would be equivalent to date +%.2d. If this doesn't work I'd suggest that ll may not use locales for that field as it is numerical.

KB
Arse-cover at all costs
James R. Ferguson
Acclaimed Contributor
Solution

Re: LC_TIME values

Hi:

First, two print with zero-fill you would specify a format like:

# date '+%02d'

Next, you might only want to make this change for the 'ls' ('ll') binary rather than system-wide. Here's a variation of a piece of code from an old HP Developer newletter that offers just this kind of ability. The original idea is not mine, but here's a modification to fit your need:

# cat /tmp/nll
#!/usr/bin/sh
# cat nll
# This script checks if a /var/tmp/ls.cat message catalog exists,
# and if not, creates one where the display formats of ls(1) are
# changed to zero-fill the day of the month.
#
# "Jan 06 08:23"
#
# It then proceeds to run ll(1) using this modified message catalog.
# Note that if root should run this, a secure locations should be
# used instead of /var/tmp.
# Usage: <script-name>
# e.g.: ./nll /etc/passwd

if [ ! -s /var/tmp/ls.cat ]; then
echo Creating /var/tmp/ls.cat >&2
dumpmsg /usr/lib/nls/msg/C/ls.cat |
sed -e "s/%b %2d/%b %02d/" |
gencat /var/tmp/ls.cat -
fi
export NLSPATH="/var/tmp/%N.cat"
exec ll "$@"

Regards!

...JRF...
HPCS France
Advisor

Re: LC_TIME values

no, the problem seems to to be somewhere else.
the correct value to put is +%d see below:
# date +%1.d
6
# date +%d
06
# date +%.2d
06
# date +%2.d
6

in the man ls for hpux 11iv1 (http://docs.hp.com/en/B2355-90689/ls.1.html)
there is:
LC_TIME determines the date and time strings output by the -g, -l (ell), -n, and -o options.

so, i can't explain why i do not arrive to do why i want.

i just try something stupid, just for test:

source LC_CTIME:
##################################
# Set up the LC_TIME category
# d_t_fmt "%A %d %B %Y %H:%M:%S"
# d_fmt "%A %d %B %Y"
# t_fmt "%H:%M:%S"
# t_fmt_ampm "%H:%M:%S"

LC_TIME
d_t_fmt ""
d_fmt ""
t_fmt ""
t_fmt_ampm ""
day ""; \
""; \
"
"; \
""; \
""; \
""; \
"
"
abday ""; \
""; \
"
"; \
""; \
""; \
""; \
"
"
mon "
"; \
""; \
"
"; \
"
"; \
"
"; \
""; \
""; \
"
"; \
"

"; \
""; \
""; \
""
abmon ""; \
""; \
"

"; \
"
"; \
"
"; \
""; \
""; \
"
"; \
"

"; \
""; \
""; \
""
am_pm "";""
year_unit ""
mon_unit ""
day_unit ""
hour_unit ""
min_unit ""
sec_unit ""
era_d_fmt ""
era ""
era_t_fmt ""
era_d_t_fmt ""
alt_digits ""
END LC_TIME

# localedef -v -c -i .src test
# export LANG=test LC_ALL=test
# locale -a |grep test
test
# locale
LANG=test
LC_CTYPE="test"
LC_CO...














































HPCS France
Advisor

Re: LC_TIME values

thanks for your workaround JRF, it will help me and make exactly what i want :).

is there a way for modify ls usage directly?
i tried to modify directly the file /usr/lib/nls/msg/C/ls.cat like the script do but that does not work.

thanks again.
HPCS France
Advisor

Re: LC_TIME values

sorry for my last message, of course in "/usr/lib/nls/msg/C/ls.cat", "C" is the locale i need to use for that works ;)))

my problem is solved now and i'm happy ;)
but "ll" does not respect its man page ;(

thanks a lot JRF.
James R. Ferguson
Acclaimed Contributor

Re: LC_TIME values

Hi (again):

Using the modified output of 'dumpmsg' provides the input to 'gencat' which is used to regenreate a catalog file. See the manpages for more information.

Regards!

...JRF...