coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

date ignores locale when parsing short dates


From: Adam Nielsen
Subject: date ignores locale when parsing short dates
Date: Fri, 21 Aug 2015 09:15:40 +1000

Hi all,

I've encountered a small issue with the way the date utility parses
textual dates.  It seems to ignore the locale settings and assume US
date formats, and I'm not sure how to get it to respect the local date
format.

For example:

  # Correct behaviour, US is dd-mm-yy
  $ LC_TIME="en_US" date +%Y-%m-%d -d 1/2/03
  2003-01-02

  # Incorrect, locale says short dates are dd-mm-yy
  $ LC_TIME="en_AU" date +%Y-%m-%d -d 1/2/03
  2003-01-02
  # Should be 2003-02-01

The locale itself seems good:

  $ LC_TIME="en_AU" date +%x -d 2003-02-01
  01/02/03

Am I doing something wrong?  I've read that -d uses the "POSIX locale"
rather than the user locale - if so, is there a way to get date's fancy
processing with mm/dd swapped to dd/mm, without resorting to regexes?

Many thanks,
Adam.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]