Different representations of time in ls -l and date(1)

Eric Blake eblake@redhat.com
Wed Aug 31 15:23:00 GMT 2016


On 08/31/2016 09:36 AM, Eric Blake wrote:

> Not necessarily.  ls hardcodes its default representation for files
> younger than 6 months to:
> 
> "%b %e %H:%M"
> 
> while date hardcodes its default representation to:
> 
> nl_langinfo(_DATE_FMT)
> 

Except that I just tested, and nl_langinfo(_DATE_FMT) for both Cygwin
and Linux is

%a %b %e %H:%M:%S %Z %Y

so something else weird is going on.

Oh duh, it's locales!  nl_langinfo() is locale-specific, and you are
(probably) running in a default locale of en_US rather than the C locale.

$ date
Wed, Aug 31, 2016  9:39:55 AM
$ LC_ALL=C
Wed Aug 31 09:43:42 CDT 2016

So, the answer to your question is determined by what your locale thinks
is the appropriate representation; and I have no control over whether
Windows' locale defaults will match glibc's locale defaults for en_US or
any other locale outside of C.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160831/bf9f471f/attachment.sig>


More information about the Cygwin mailing list