bug-coreutils
[Top][All Lists]
Advanced

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

Re: [bug #21455] date --date "" "+test" fails ONLY WITHIN CERTAIN TIME P


From: Philip Rowlands
Subject: Re: [bug #21455] date --date "" "+test" fails ONLY WITHIN CERTAIN TIME PERIOD #$%^%
Date: Mon, 29 Oct 2007 16:54:27 +0000 (GMT)

On Mon, 29 Oct 2007, Mischa Molhoek wrote:

ok, here is the text version, because the image is remove by accident :)

It's simpler to debug problems reported by text, not pictures.

[titan: mischa] ~> date --version
date (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
[titan: mischa] ~> date --date "" "+test"
test

[titan: mischa] ~> sudo date -s "Sun Oct 28 22:00:53 CET 2007"
Sun Oct 28 22:00:53 CET 2007

[titan: mischa] ~> date --date "" "+test"
date: invalid date `'

You don't need the "+test", it's invalid by itself :)

[titan: mischa] ~> sudo rdate -s ntp.xs4all.nl

[titan: mischa] ~> date
Mon Oct 29 12:08:41 CET 2007

[titan: mischa] ~> date --date "" "+test"
test

You don't give your timezone explicitly, so I'm going to guess you're in a region which follows Central European Time / Central European Summer Time.

I hacked up the following to avoid resetting my system clock all over the place:

--------- clock_gettime.c -----------
#include <stdlib.h>
#include <time.h>
#include <errno.h>

int clock_gettime(clockid_t clk_id, struct timespec *tp) {
        if (clk_id != CLOCK_REALTIME) {
                errno = EINVAL;
                return -1;
        }
        char *faketime = getenv("FAKETIME");
        if (! faketime ) {
                errno = EINVAL;
                return -1;
        }
        if (tp) {
                tp->tv_nsec = 0;
                tp->tv_sec = atol(faketime);
        }
        return 0;
}
-------------------------------------

gcc -c -fPIC clock_gettime.c -D_GNU_SOURCE
gcc -shared -fPIC -o clock_gettime.so clock_gettime.o
for anyone following at home.

Firstly, let's see what date -d "" does?

$ date -d ""
Mon Oct 29 00:00:00 GMT 2007

This has shown my current time wound back to the previous midnight. (I can't find the documentation which describes this, but let's continue regardless.)

$ export TZ=Europe/Paris
$ export FAKETIME=1193605253; LD_PRELOAD=./clock_gettime.so date -d ""
date: invalid date `'

Smells like a DST issue, are we in a DST change?

$ zdump -v Europe/Paris
Europe/Paris  Sun Oct 28 00:59:59 2007 UTC = Sun Oct 28 02:59:59 2007 CEST 
isdst=1 gmtoff=7200
Europe/Paris  Sun Oct 28 01:00:00 2007 UTC = Sun Oct 28 02:00:00 2007 CET 
isdst=0 gmtoff=3600

In Europe/Paris, the boundaries of "invalid" times are 1193533200 -> 1193612399 inclusive, or
Sun Oct 28 02:00:00 CET 2007 -> Sun Oct 28 23:59:59 CET 2007

If I try the same thing in Europe/Dublin, invalid times become
1193533200 - 1193615999 inclusive, or
Sun Oct 28 01:00:00 GMT 2007 -> Sun Oct 28 23:59:59 GMT 2007

This corresponds to the first second of winter time "isdst=0" and persists for the rest of the logical day. I'm wary about diving around in unfamiliar code - perhaps someone more familiar with date parsing knows how date -d "" is supposed to be treated, and what the problem is here?


Cheers,
Phil




reply via email to

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