You are not logged in.

#1 2015-11-11 12:07:41

e.sovetkin
Member
From: Aachen
Registered: 2013-04-05
Posts: 28

[SOLVED] Problem with a 'date' command. Bug?

Hello everyone,

I have a funny little problem with the 'date' command. I have two machines with arch installed on it. On one of them I can run the following command without any problems:

 % date -d "$(date)"

which returns me the current date. Running the same command on another machine with the same bash/zsh/locale/... configuration (both machines are updated) returns me an error:

 % date -d "$(date)"
  date: invalid date ‘...’

I cannot grasp what could cause such a behaviour...

Any advice and help are appreciated.

Last edited by e.sovetkin (2015-11-11 12:19:40)

Offline

#2 2015-11-11 12:10:39

dice
Member
From: Germany
Registered: 2014-02-10
Posts: 413

Re: [SOLVED] Problem with a 'date' command. Bug?

Seems to be locale dependent on my machine:

% date -d "$(date)"
date: invalid date ‘Mi 11. Nov 13:08:32 CET 2015’
% date -d "$(LC_ALL=C date)"                                                                                    
Mi 11. Nov 13:08:50 CET 2015
% locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_COLLATE="en_US.utf8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.utf8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=

I put at button on it. Yes. I wish to press it, but I'm not sure what will happen if I do.  (Gune | Titan A.E.)

Offline

#3 2015-11-11 12:22:17

e.sovetkin
Member
From: Aachen
Registered: 2013-04-05
Posts: 28

Re: [SOLVED] Problem with a 'date' command. Bug?

Indeed, thanks for the quick reply!

The difference was in locale in en_US and en_GB, and setting LC_ALL=C solves the problem.

I shall be aware of these locale setting in scripts now!

dice wrote:

Seems to be locale dependent on my machine:

% date -d "$(date)"
date: invalid date ‘Mi 11. Nov 13:08:32 CET 2015’
% date -d "$(LC_ALL=C date)"                                                                                    
Mi 11. Nov 13:08:50 CET 2015
% locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_COLLATE="en_US.utf8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.utf8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=

Offline

Board footer

Powered by FluxBB