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: O. Emmerson
Subject: bug#35289: closed (Re: bug#35289: date+%-Y -d "- N years" errors when N > 111)
Date: Tue, 16 Apr 2019 00:10:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 15/04/2019 21:55, Assaf Gordon wrote:
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?

For me it gives:

$ ./inv-year
time() = 1555369320
localtime() = 2019-04-16 00:02:00
              (mday=16 wday=2, isdst=1)
struct tm (after adjustment) = 0009-04-16 00:02:00
                               (mday=16 wday=2, isdst=1)
inv-year: mktime() failed: Value too large for defined data type


And debug gives:

$ date +%-Y -d "- 112 years" --debug
date: parsed relative part: -112 year(s)
date: input timezone: system default
date: using current time as starting value: '00:04:32'
date: using current date as starting value: '(Y-M-D) 2019-04-16'
date: starting date/time: '(Y-M-D) 2019-04-16 00:04:32'
date: warning: when adding relative months/years, it is recommended to
specify the 15th of the months
date: error: adding relative date resulted in an invalid date: '(Y-M-D)
1907-04-16 00:04:32'
date: invalid date ‘- 112 years’







reply via email to

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