[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EPOCHREALTIME does not behave correctly before 1970
From: |
Kerin Millar |
Subject: |
Re: EPOCHREALTIME does not behave correctly before 1970 |
Date: |
Mon, 23 Aug 2021 00:52:36 +0100 |
On Sun, 22 Aug 2021 16:13:28 -0400
Chet Ramey <chet.ramey@case.edu> wrote:
> On 8/21/21 1:28 AM, Emanuele Torre wrote:
>
> > Bash Version: 5.1
> > Patch Level: 8
> > Release Status: release
> >
>
> > get_epochrealtime() casts tv.tv_sec (a time_t a.k.a. int) to unsigned
> > int causing EPOCHREALTIME to not behave correctly before the Unix Epoch.
>
> The definition is seconds since the Unix epoch. It's not surprising that it
> doesn't pay attention to dates before that.
The problem with this statement is that EPOCHREALTIME is permitted to get it
wrong, yet EPOCHSECONDS is permitted to get it right. The discrepancy certainly
came as a surprise to me.
$ TZ=UTC faketime '1970-01-01' bash -c 'declare -p EPOCHSECONDS'
declare -- EPOCHSECONDS="0"
$ TZ=UTC faketime '1969-12-31' bash -c 'declare -p EPOCHSECONDS'
declare -- EPOCHSECONDS="-86400"
--
Kerin Millar