Fix: trimmer: use regexes to parse dates and times
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 6 Jun 2019 20:59:44 +0000 (16:59 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 3 Jul 2019 20:36:15 +0000 (16:36 -0400)
commitd4d7ffc9b2ac45125334268754c11c4a57c7de66
tree936f2e6b0f379541e5d9b8b7c90bebe31252a014
parent1af7795bba1a6f1a851cedc3434061fcad7e0adc
Fix: trimmer: use regexes to parse dates and times

This patch fixes a few issues related to how the trimmer component
parses timestamps.

1. Less than 9 digits in the nanoseconds position is not interpreted
   correctly.

   Passing "2019-01-02 12:34:56.444", we expect the nanosecond portion
   to mean 444 ms, or 444000000 ns.  Currently, it is interpreted as 444
   ns.

2. We wrongfully accept missing digits in the various fields

   It is currently possible to pass a date as "2019-1-2" (instead of
   "2019-01-02") or a time as "1:2:3" (instead of "01:02:03").  This
   patch makes the parsing stricter, in order to only accept the right
   number of digits when parsing dates (in the form "YYYY-MM-DD") and
   times (in the form "HH:MM:SS").  The nanosecond portion, if present,
   can contain anywhere from 1 to 9 digits.

Change-Id: Ie315cec0bc7387ecdaa999d6c5f82f70035412f3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1389
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/utils/trimmer/trimmer.c
tests/cli/test_trimmer
This page took 0.025616 seconds and 4 git commands to generate.