diff options
author | David Perry <boolean263@protonmail.com> | 2021-01-08 09:18:39 +0000 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2021-01-08 09:18:39 +0000 |
commit | b758fdaede7960db9f86786b91c7b23e80210e6f (patch) | |
tree | 5e5d61dc5da72185a540f0abe4efdbf9224c57f6 /wsutil/time_util.h | |
parent | 73cef353bf4bf6ed5b59af2089112e0144fd9b94 (diff) |
Add iso8601_to_nstime() for editcap and nettrace
This adds a function to parse a string date-time in ISO 8601 format into
a `nstime_t` structure. It's based on code from epan/tvbuff.c and
wiretap/nettrace_3gpp_32_423.c and meant to eventually replace both.
(Currently only replaces the latter.)
Since most of Wireshark expects ISO 8601 date-times to fit a fairly
strict pattern, iso8601_to_nstime() currently rejects date-times without
separators between the components, even though ISO 8601 actually permits
this. This could be revisited later.
Also uses iso8601_to_nstime in editcap to parse the -A/-B options,
thus allowing the user to specify a time zone if desired. (See #17110)
Diffstat (limited to 'wsutil/time_util.h')
-rw-r--r-- | wsutil/time_util.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/wsutil/time_util.h b/wsutil/time_util.h index 1cd430dedf..99d97d662e 100644 --- a/wsutil/time_util.h +++ b/wsutil/time_util.h @@ -18,9 +18,21 @@ extern "C" { #include <time.h> +/** Converts a broken down date representation, relative to UTC, + * to a timestamp + */ WS_DLL_PUBLIC time_t mktime_utc(struct tm *tm); +/** Validate the values in a time_t. + * Currently checks tm_year, tm_mon, tm_mday, tm_hour, tm_min, and tm_sec; + * disregards tm_wday, tm_yday, and tm_isdst. + * + * @param tm The struct tm to validate. + */ +WS_DLL_PUBLIC +gboolean tm_is_valid(struct tm *tm); + /** Fetch the process CPU time. * * Fetch the current process user and system CPU times, convert them to |