From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Petr Mladek <pmladek@suse.com>
Cc: JC Kuo <jckuo@nvidia.com>, Joe Perches <joe@perches.com>,
Sumit Garg <sumit.garg@linaro.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-nilfs@vger.kernel.org,
kgdb-bugreport@lists.sourceforge.net,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jonathan Corbet <corbet@lwn.net>,
Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Ryusuke Konishi <konishi.ryusuke@gmail.com>,
Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <daniel.thompson@linaro.org>,
Douglas Anderson <dianders@chromium.org>
Subject: Re: [PATCH v1 1/4] lib/vsprintf: Allow to override date and time separator
Date: Tue, 11 May 2021 17:56:56 +0300 [thread overview]
Message-ID: <YJqbONasNp9BXx9Q@smile.fi.intel.com> (raw)
In-Reply-To: <YJqRYNlAu0SfWpb5@alley>
On Tue, May 11, 2021 at 04:14:56PM +0200, Petr Mladek wrote:
> On Mon 2021-05-10 18:04:10, Andy Shevchenko wrote:
> > ISO 8601 defines 'T' as a separator between date and time. Though,
> > some ABIs use time and date with ' ' separator instead.
> >
> > Add a flavour to the %pt specifier to override default separator.
...
> > %pt[RT] YYYY-mm-ddTHH:MM:SS
> > + %pt[RT]s YYYY-mm-dd HH:MM:SS
> > %pt[RT]d YYYY-mm-dd
> > %pt[RT]t HH:MM:SS
> > - %pt[RT][dt][r]
> > + %pt[RT][dt][rs]
>
> Sigh, we do not have clear rules what [xy] means. It might be:
>
> + always use one of them
> + optionally use one of them
> + always use any of them
> + optionally use any of them
>
> %pt[RT][dt][rs] is a great mix:
>
> + R or T is required, the rest is optional
> + 'd' or 't' can be used but both together are not supported
> + any variant of 'r' and 's' is supported including various ordering
>
> Honestly, I do not know about any magic solution that might make it
> easier to understand these monster modifiers.
>
> Well, what about using the following at least in this case:
>
> %pt[RT][dt][r][s]
>
> It might help to understand that both 'r' and 's' can be used at the
> same time.
This is the case, yes, thanks for catching it.
> An attempt to distinguishing all the possibilities might be:
>
> %pt{RT}[{dt}][r][s]
>
> where [] means that it is optional and {} means one of them must be
> chosen. But I am not sure if it really makes the life easier. Anyway,
> this would be for another patch that updates the entire printk-formats.rst.
No, this is not the case, the d and t can go in any combinations: none, d, t,
dt, or td.
>
> > For printing date and time as represented by::
> >
> > @@ -528,6 +529,9 @@ in human readable format.
> > By default year will be incremented by 1900 and month by 1.
> > Use %pt[RT]r (raw) to suppress this behaviour.
> >
> > +The %pt[RT]s (space) will override ISO 8601 by using ' ' instead of 'T'
> > +between date and time. It won't have any effect when date or time is omitted.
...
> > + do {
> > + switch (fmt[count++]) {
> > + case 'r':
> > + raw = true;
> > + break;
> > + case 's':
> > + space = true;
> > + break;
> > + default:
> > + found = false;
> > + break;
> > + }
> > + } while (found);
> >
> > if (have_d)
> > buf = date_str(buf, end, tm, raw);
> > if (have_d && have_t) {
> > /* Respect ISO 8601 */
>
> The comment is slightly misleding now. What about something like?
>
> /* 'T' by ISO 8601. */
>
> Or maybe call the variable: iso_8601, remove the comment, and
> invert the logic:
Okay, I will think how to improve, thanks!
> bool iso_8601 = true;
>
> case 's':
> iso_8601 = false;
> break;
>
> *buf = iso_8601 ? 'T' : ' ';
>
> > if (buf < end)
> > - *buf = 'T';
> > + *buf = space ? ' ' : 'T';
> > buf++;
> > }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2021-05-11 14:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 15:04 [PATCH v1 1/4] lib/vsprintf: Allow to override date and time separator Andy Shevchenko
2021-05-10 15:04 ` [PATCH v1 2/4] kdb: Switch to use %ptTs Andy Shevchenko
2021-05-11 0:05 ` Doug Anderson
2021-05-11 7:14 ` Andy Shevchenko
2021-05-11 14:16 ` Petr Mladek
2021-05-10 15:04 ` [PATCH v1 3/4] nilfs2: " Andy Shevchenko
2021-05-11 14:16 ` Petr Mladek
2021-05-10 15:04 ` [PATCH v1 4/4] usb: host: xhci-tegra: " Andy Shevchenko
2021-05-11 14:16 ` Petr Mladek
2021-05-11 14:14 ` [PATCH v1 1/4] lib/vsprintf: Allow to override date and time separator Petr Mladek
2021-05-11 14:56 ` Andy Shevchenko [this message]
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=YJqbONasNp9BXx9Q@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jason.wessel@windriver.com \
--cc=jckuo@nvidia.com \
--cc=joe@perches.com \
--cc=jonathanh@nvidia.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=konishi.ryusuke@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mathias.nyman@intel.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=sumit.garg@linaro.org \
--cc=thierry.reding@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).