Re: [PATCH 1/2] date.c: allow fractional second part of ISO-8601
On 2020-04-14 23:49:58+0000, "brian m. carlson" <sandals@crustytoothpaste.net> wrote:
Show 24 quoted lines
> On 2020-04-14 at 20:17:33, Jeff King wrote:
> > On Tue, Apr 14, 2020 at 04:31:54PM +0700, Đoàn Trần Công Danh wrote:
> >
> > > diff --git a/date.c b/date.c
> > > index b0d9a8421d..2f37397beb 100644
> > > --- a/date.c
> > > +++ b/date.c
> > > @@ -556,6 +556,8 @@ static int match_multi_number(timestamp_t num, char c, const char *date,
> > > case ':':
> > > if (num3 < 0)
> > > num3 = 0;
> > > + else if (*end == '.' && isdigit(end[1]))
> > > + strtol(end + 1, &end, 10);
> >
> > This just throws away the fractional part. I doubt anybody cares much
> > either way, but another option would be to round num3 up or down.
>
> I'm happy with truncation. It's simple and straightforward and will be
> widely and intuitively understood by programmers, who are probably the
> primary users of our ISO 8601 handling.
>
> I do appreciate that you pointed this out, because it's a good point.
>
> And overall, I agree that this seems like a good fix for the problem.
I'll reword the subject to "throw away fractional second part of ISO-8601"
1 second is not that big, and and the logic is simpler.
--
Danh