Bug 1124882 - date fails to parse dates bigger than INT_MAX on 32bit arch
Summary: date fails to parse dates bigger than INT_MAX on 32bit arch
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: coreutils
Version: 7.2
Hardware: Unspecified
OS: Linux
medium
high
Target Milestone: alpha
: 7.4
Assignee: Kamil Dudka
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-30 14:32 UTC by Aleš Mareček
Modified: 2019-07-01 17:30 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description Aleš Mareček 2014-07-30 14:32:46 UTC
Description of problem:
date fails to parse dates bigger than INT_MAX (2147483647), 32-bit architecture.

Version-Release number of selected component (if applicable):
Always

How reproducible:
coreutils-8.4-31.el6.i686
date (GNU coreutils) 8.4

Steps to Reproduce:
1. date -d "2038-01-19 04:14:08" "+%s"

Actual results:
date: invalid date `2038-01-19 04:14:08'

Expected results:
2147483648

Additional info:
i:i386|m:i686 root@x86-64-v06 [~]# date -d "2038-01-19 04:14:07" "+%s"
2147483647
i:i386|m:i686 root@x86-64-v06 [~]# date -d "2038-01-19 04:14:08" "+%s"
date: invalid date `2038-01-19 04:14:08'

Comment 2 Pádraig Brady 2014-07-30 16:31:40 UTC
The limitation here stems from the glibc and kernel representation of time_t
which on 32 bit x86 at least is long, i.e. 31 bits.

Now theoretically we could work around this by defining time64_t, mktime64(), localtime64() in gnulib, and parse_datetime() etc. would use those.

Those functions in turn could call out to _time64() on windows,
or otherwise on signed 32 bit time_t systems, handle at least the 32 bit wrap,
thus handling dates until 2106.

We could split the problem by only implementing mktime64() in gnulib,
and thus supporting absolute times like in the above report without
needing to worry about the kernel interface required for relative times.

Though would it be worth doing that, when 64 bit supports this already?

What's the use case for this exactly?

Comment 4 Aleš Mareček 2014-07-31 09:19:19 UTC
Greetings,
thank you for your quick response at first.
We use this datetime functions in certificate testing what is broken on 32-bit archs. Timestamp is basic commonly used data type and shouldn't be faulty.
Thanks and Regards!


Note You need to log in before you can comment on or make changes to this bug.