bug-coreutils
[Top][All Lists]
Advanced

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

bug#35289: closed (Re: bug#35289: date+%-Y -d "- N years" errors when N


From: Assaf Gordon
Subject: bug#35289: closed (Re: bug#35289: date+%-Y -d "- N years" errors when N > 111)
Date: Mon, 15 Apr 2019 14:55:42 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Thanks Bernhard,

On 2019-04-15 2:14 p.m., Bernhard Voelker wrote:
I can easily reproduce here on my regular openSUSE:Tumbleweed from latest git:

   $ src/date --debug '+%-Y' -d '- 2010 years'
[....]
   date: error: adding relative date resulted in an invalid date: '(Y-M-D) 
0009-04-15 22:10:37'

This makes it easy to pinpoint (hooray for "--debug" :) ).

This error is given if gnulib's "mktime_z" fails
to convert the adjusted "struct tm" to "time_t"
(adjusted because its tm_year was decremented by 2010).

https://opengrok.housegordon.com/source/xref/gnulib/lib/parse-datetime.y#2177

To see if this is glibc issue, or perhaps an gnulib/mktime_z wrapper
issue, can you (and/or others) try the attached C program?

It calls time(2)+localtime(3)+mktime(3) to emulate the date adjustment.

Because the adjustment is to year 9 (about 1961 years before epoch),
the time_t value is negative. perhaps that's the issue? or perhaps
combined with a specific timezone it becomes problematic?

On my system it gives:
----
  $ gcc -o inv-year inv-year.c

  $ ./inv-year
  time() = 1555361050
  localtime() = 2019-04-15 14:44:10
                (mday=15 wday=1, isdst=1)
  struct tm (after adjustment) = 0009-04-15 14:44:10
                                 (mday=15 wday=1, isdst=1)
  mktime() after date adjustment = -61874070118
----


regards,
 - assaf






Attachment: inv-year.c
Description: Text Data


reply via email to

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