From: Stephan Beyer <s-beyer@gmx.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: sverre@rabbelier.nl, Brandon Casey <casey@nrlssc.navy.mil>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Date parsing
Date: Sat, 21 Jun 2008 23:52:40 +0200 [thread overview]
Message-ID: <20080621215240.GD15111@leksak.fem-net> (raw)
In-Reply-To: <alpine.LFD.1.10.0806100942500.3101@woody.linux-foundation.org>
Hi,
> > On Tue, Jun 10, 2008 at 5:10 PM, Brandon Casey <casey@nrlssc.navy.mil> wrote:
> > > Take a look at match_multi_number in date.c
> > > European ordering is preferred when the separator is '.'
> >
> > Ok, then I'll use . in the future, that's nice :).
>
> Well, there are safer ways to give the date.
>
> If you do it in strict rfc822 format, you'll never have any confusion
> what-so-ever. The "approxidate()" thing tries to parse any random input,
> but it *is* meant to be excessively liberal.
Today I've been playing around with approxidate(), too, and I think I
found some bug in date parsing. I let copy&paste speak...
Correct:
$ ./test-date "2008-07-01 23:59:59 +0200"
2008-07-01 23:59:59 +0200 -> 1214949599 +0200 -> Tue Jul 1 23:59:59 2008
2008-07-01 23:59:59 +0200 -> Tue Jul 1 23:59:59 2008
And even:
$ ./test-date "2008-07-01 24:00:00 +0200"
2008-07-01 24:00:00 +0200 -> 1214949600 +0200 -> Wed Jul 2 00:00:00 2008
2008-07-01 24:00:00 +0200 -> Wed Jul 2 00:00:00 2008
But then there's a jump in time:
$ ./test-date "2008-07-02 00:00:00 +0200"
2008-07-02 00:00:00 +0200 -> 1202335200 +0200 -> Wed Feb 6 23:00:00 2008
2008-07-02 00:00:00 +0200 -> Wed Feb 6 23:00:00 2008
$ ./test-date "2008-07-02 01:00:00 +0200"
2008-07-02 01:00:00 +0200 -> 1202338800 +0200 -> Thu Feb 7 00:00:00 2008
2008-07-02 01:00:00 +0200 -> Thu Feb 7 00:00:00 2008
If we let test-date just print the timestamp...
diff --git a/test-date.c b/test-date.c
index 62e8f23..18d53c1 100644
--- a/test-date.c
+++ b/test-date.c
@@ -11,10 +11,10 @@ int main(int argc, char **argv)
memcpy(result, "bad", 4);
parse_date(argv[i], result, sizeof(result));
t = strtoul(result, NULL, 0);
- printf("%s -> %s -> %s", argv[i], result, ctime(&t));
+ printf("%s -> %lu\n", argv[i], t);
t = approxidate(argv[i]);
- printf("%s -> %s\n", argv[i], ctime(&t));
+ printf("%s -> %lu\n", argv[i], t);
}
return 0;
}
-- -- -- --
... then we get:
$ ./test-date "2008-07-01 23:59:59 +0200"
2008-07-01 23:59:59 +0200 -> 1214949599
2008-07-01 23:59:59 +0200 -> 1214949599
$ ./test-date "2008-07-02 00:00:00 +0200"
2008-07-02 00:00:00 +0200 -> 1202335200
2008-07-02 00:00:00 +0200 -> 1202335200
Also, with another timezone, we get:
$ ./test-date "2008-07-01 23:59:59 +0000"
2008-07-01 23:59:59 +0000 -> 1214956799
2008-07-01 23:59:59 +0000 -> 1214956799
$ ./test-date "2008-07-02 00:00:00 +0000"
2008-07-02 00:00:00 +0000 -> 1202342400
2008-07-02 00:00:00 +0000 -> 1202342400
Is something wrong in my format or is there a bug?
Providing timestamps works, of course ;-)
Regards,
Stephan
--
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
next prev parent reply other threads:[~2008-06-21 21:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-10 14:58 Date parsing Sverre Rabbelier
2008-06-10 15:07 ` Johannes Sixt
2008-06-10 15:27 ` Sverre Rabbelier
2008-06-10 15:10 ` Brandon Casey
2008-06-10 15:31 ` Sverre Rabbelier
2008-06-10 16:55 ` Linus Torvalds
2008-06-10 17:51 ` Sverre Rabbelier
2008-06-21 21:52 ` Stephan Beyer [this message]
2008-06-21 22:28 ` Linus Torvalds
2008-06-21 22:37 ` Linus Torvalds
2008-06-21 22:40 ` Stephan Beyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080621215240.GD15111@leksak.fem-net \
--to=s-beyer@gmx.net \
--cc=casey@nrlssc.navy.mil \
--cc=git@vger.kernel.org \
--cc=sverre@rabbelier.nl \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox