bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Ulf Zibis
Am 15.03.2017 um 16:53 schrieb Pádraig Brady: "coreutils FAQ" By the way, I think there is a typo: $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B.' Last month was June. $ date --date="$(date +%Y-%m-15) +1 month" +'Next month will be %B.' Next month will be May. Compared

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Ulf Zibis
Am 15.03.2017 um 15:46 schrieb Eric Blake: List policy is to reply-to-all, so that we don't have to think about who is subscribed, while making sure that even unsubscribed readers stay in the loop on the message they are interested in. The list server has settings where you can request that

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Ulf Zibis
Am 15.03.2017 um 15:40 schrieb Assaf Gordon: To give more details about the inter working of date adjustments: Much thanks for outlining these details in great clarity. You'd like to be able to do date calculations in some predictable way, Yes! Currently the result is not predictable

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Assaf Gordon
Correcting my own mistake: > On Mar 15, 2017, at 10:40, Assaf Gordon wrote: > > When adjusting days, it is equivalent to subtracting > the number of seconds from the current unix epoch (i.e. seconds since > 1970-01-01). > [...] Adjusting days is equivalent to adjusting

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Assaf Gordon
Hello, > On Mar 15, 2017, at 11:53, Pádraig Brady wrote: > > Yes that's an awkward gotcha (I'm not sure is related to the OP's issue). > I outlined a solution at http://bugs.gnu.org/18159#8 > I didn't document in "coreutils gotchas" as it's covered in "coreutils FAQ", >

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Pádraig Brady
On 15/03/17 05:44, Eric Blake wrote: > On 03/15/2017 07:23 AM, Ulf Zibis wrote: > >> >> A more simple example without touch: >> $ date +%F >> 2017-03-15 >> $ date -d "-20 day" +%F >> 2017-02-23 >> $ date -d "-20 day -2 month" +%F >> 2016-12-26 >> $ date -d "-2 month -20 day" +%F >> 2016-12-26 >>

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Eric Blake
On 03/15/2017 08:43 AM, Ulf Zibis wrote: > > Am 15.03.2017 um 13:44 schrieb Eric Blake: >> Maybe you are confused on how date implements "subtract a month". It >> does NOT do "subtract 28, 29, 30, or 31 days as appropriate", but rather >> does "subtract 30 days, for lack of anything better to

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Assaf Gordon
quot;). When adjusting days, it is equivalent to subtracting the number of seconds from the current unix epoch (i.e. seconds since 1970-01-01). Example: Current unix time: $ date -d '20170315' +%s 1489536000 Number of days you want to subtract, in seconds: $ bc -l<<<'360*8640

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Ulf Zibis
Am 15.03.2017 um 13:44 schrieb Eric Blake: Maybe you are confused on how date implements "subtract a month". It does NOT do "subtract 28, 29, 30, or 31 days as appropriate", but rather does "subtract 30 days, for lack of anything better to do". Are you really sure ??? Here on my 8.25 version

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Eric Blake
On 03/15/2017 07:23 AM, Ulf Zibis wrote: > > A more simple example without touch: > $ date +%F > 2017-03-15 > $ date -d "-20 day" +%F > 2017-02-23 > $ date -d "-20 day -2 month" +%F > 2016-12-26 > $ date -d "-2 month -20 day" +%F > 2016-12-26 > > In the 2nd example I would expect: > 2016-12-23

bug#26101: Counterproductive calculation order in date

2017-03-15 Thread Ulf Zibis
Eric, much thanks for your detailed examination. Am 15.03.2017 um 02:21 schrieb Eric Blake: Let's try this with the new --debug option of 8.26 Great, but current version of my Ubuntu is 8.25 $ date --debug -d "$(($(date -r ChangeLog +%s)-$(date +%s))) seconds -2 months" date: parsed