All of lore.kernel.org
 help / color / mirror / Atom feed
From: Assaf Gordon <assafgordon@gmail.com>
To: Karel Zak <kzak@redhat.com>
Cc: J William Piggott <elseifthen@gmx.com>, util-linux@vger.kernel.org
Subject: Re: [V2 0/4] hwclock: remove date(1)
Date: Tue, 28 Feb 2017 17:01:23 +0000	[thread overview]
Message-ID: <20170228170122.GA18228@gmail.com> (raw)
In-Reply-To: <20170228161000.ijlouecku6a37quk@ws.net.home>

Hello,

On Tue, Feb 28, 2017 at 05:10:00PM +0100, Karel Zak wrote:
>On Tue, Feb 28, 2017 at 10:23:39AM -0500, J William Piggott wrote:
>> My impression is that the original parse_datetime() is stable. It seems
>> like most of the changes now involve parse_datetime2() to expand
>> capabilities.

More specifically: parse_datetime was made it re-entrant (removed 
global timezone  variables) and was added debugging code.
I don't think the parser itself has changed in a long while.

>Fortunately, this stuff is easy to test, so we can create regression
>tests for all the possible formats to be sure we do not introduce any
>regression.

A description of all types of accepted inputs for gnu date
(and techincally: gnulib's parse_datetime) is here:
 https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html

>> > I guess it will be possible to move it to lib/parse-datetime.c and use
>> > it on another places in util-linux (instead of our minimalistic
>> > parse_datetime()), right?
>>
>> Sure, I think a name change to avoid confusion with gnulib would be
>> good. Maybe just parse_date.c?

If you copy the gnulib's parser and adjust it,
I might suggest doing away first with relative times,
then perhaps with timezones.

There are some confusing combinations, especially with
relative times (e.g. "20170228 + 2 days" vs "20:45:45 + 2 days", the 
latter parsed as "8:45:45pm+02:00TZ + 1 day"),
and then with all sorts of things that are taken as timezones (like 
"2017A" which is parsed as '8:17pm in timezone -01:00'.

If you don't want to meddle with the parser (which is understandable),
as a fallback you might want to add a minor piece of code
that ensures any timezone/relative parts were not encountered during the 
parsing.
To do that, I'd add a small check at the end of 'parse_datetime2',
and look at the fields of 'struct parse_control':
http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/parse-datetime.y#n172

something like:

    if (pc.dsts_seen==0 && pc.rels_seen==0 && pc.zones_seen==0 etc.)

Then the parser didn't encounter these parts.

I'm happy to help with testing if needed.

regards,
 - assaf

P.S.
In fact, I wonder if it'll be easier to add such a flag to gnulib's 
parse_datetime2 , something like 'PARSE_DATETIME_NO_RELATIVE'
and 'PARSE_DATETIME_NO_ZONE' which will reject such input.

  reply	other threads:[~2017-02-28 17:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25 18:25 [V2 0/4] hwclock: remove date(1) J William Piggott
2017-02-25 18:28 ` [V2 1/4] hwclock: use parse_datetime function J William Piggott
2017-02-25 18:30 ` [V2 2/4] build-system: add hwclock-date J William Piggott
2017-02-25 18:32 ` [V2 3/4] hwclock: add hwclock-date files J William Piggott
2017-02-25 18:33 ` [V2 4/4] hwclock: add sys-utils/hwclock-date.c J William Piggott
2017-02-28 13:37 ` [V2 0/4] hwclock: remove date(1) Karel Zak
2017-02-28 15:23   ` J William Piggott
2017-02-28 16:10     ` Karel Zak
2017-02-28 17:01       ` Assaf Gordon [this message]
2017-03-04 21:57         ` J William Piggott
2017-03-02 11:43     ` [PATCH] lib: add parse-date.y Karel Zak

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=20170228170122.GA18228@gmail.com \
    --to=assafgordon@gmail.com \
    --cc=elseifthen@gmx.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.