GNU bug report logs - #26101
Counterproductive calculation order in date

Previous Next

Package: coreutils;

Reported by: Ulf Zibis <Ulf.Zibis <at> gmx.de>

Date: Wed, 15 Mar 2017 00:42:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ulf Zibis <Ulf.Zibis <at> gmx.de>
To: 26101 <at> debbugs.gnu.org
Subject: bug#26101: Counterproductive calculation order in date
Date: Wed, 15 Mar 2017 01:17:07 +0100
[Message part 1 (text/plain, inline)]
Hi,

with
    $ date -r test
I get:
    Di 10. Jan 22:39:14 CET 2017
but with
    $ date -d "$(($(date -r test +%s)-$(date +%s))) seconds -2 months"
I get:
   Sa 12. Nov 22:39:14 CET 2016

I think the better result would be according to a calculation order from 
left to right:
   Sa 10. Nov 22:39:14 CET 2016

Otherwise it seems impossible to correctly change the time stamp of a 
file relative to its current value.
Example:
    $ touch -t $(date -d "$(($(date -r test +%s)-$(date +%s))) seconds 
-2 months" +%Y%m%d%H%M.%S) test
Additionally the command is not correctly reversible with:
    $ touch -t $(date -d "$(($(date -r test +%s)-$(date +%s))) seconds 
+2 months" +%Y%m%d%H%M.%S) test

Regards
Ulf

[smime.p7s (application/pkcs7-signature, attachment)]

This bug report was last modified 6 years and 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.