Subject: Re: strftime %X control: how?
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Greg A. Woods <woods@planix.com>
List: tech-userlevel
Date: 07/05/2007 17:28:38
--pgp-sign-Multipart_Thu_Jul__5_17:28:36_2007-1
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

At Thu, 5 Jul 2007 14:03:21 -0400 (EDT), der Mouse wrote:
Subject: strftime %X control: how?
>=20
> Normally I run with nothing locale-specific in my environment, which I
> think means I get the C locale.

Indeed.

> But this means that atq prints dates as xx/xx/xx, which is horrible.  I
> want standard ISO date format, but I otherwise want what I have now.
> My question is, how can I get this?

I don't think you can, yet.  From setlocale(3)'s BUGS in everything up
to at least netbsd-4:

     The current implementation supports only the "C" and "POSIX"
     locales for all but the LC_CTYPE locale.

Indeed the code for setlocale(3) in netbsd-4 shows that nothing is done
for LC_TIME, and there are no specifications for LC_TIME features in
/usr/share/locale.


> After a little digging, it appears to me that I need to set $LC_TIME,
> but I haven't found any clue what to set it to.  Am I missing
> something, or is there just no way to get standard dates out of %X at
> present?

Further noted in setlocale(3):

	LC_NUMERIC and LC_TIME are personal choices and should
     not be wrapped up with the other categories.

P1003.2/D11.2 said:

    at          The at and cron family of utilities were omitted because
                portable applications could not rely on their behavior.
                [POSIX.2a]

however the Single UNIX Specification v2 documents "at -l" as using
LC_TIME to "determine the format and contest for date and time strings
written...."

Personally I don't think it should be possible to personalize the date
formats used in standard reports produced by command-line tools.  They
should always be in the most appropriate standard format regardless of
locale.  E.g. strftime("%F-%T%z");

--=20
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>

--pgp-sign-Multipart_Thu_Jul__5_17:28:36_2007-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: mKrcRz6LFKpqNb/XY05p6hI3M1W3o8h8

iQA/AwUBRo1ihWZ9cbd4v/R/EQLJrQCfbioVu7SuHiX4lprXSthGdVyZlBwAnj0j
G9EAU0j1YemT3sykfHM6LLCX
=9ILC
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Thu_Jul__5_17:28:36_2007-1--