aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/nstime.h
diff options
context:
space:
mode:
authorDavid Perry <boolean263@protonmail.com>2021-01-08 09:18:39 +0000
committerAndersBroman <a.broman58@gmail.com>2021-01-08 09:18:39 +0000
commitb758fdaede7960db9f86786b91c7b23e80210e6f (patch)
tree5e5d61dc5da72185a540f0abe4efdbf9224c57f6 /wsutil/nstime.h
parent73cef353bf4bf6ed5b59af2089112e0144fd9b94 (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/nstime.h')
-rw-r--r--wsutil/nstime.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/wsutil/nstime.h b/wsutil/nstime.h
index 6c50e1fb92..2292b6f811 100644
--- a/wsutil/nstime.h
+++ b/wsutil/nstime.h
@@ -11,6 +11,7 @@
#ifndef __NSTIME_H__
#define __NSTIME_H__
+#include <glib.h>
#include <time.h>
#include "ws_symbol_export.h"
@@ -122,6 +123,11 @@ WS_DLL_PUBLIC gboolean filetime_to_nstime(nstime_t *nstime, guint64 filetime);
FALSE on failure */
WS_DLL_PUBLIC gboolean nsfiletime_to_nstime(nstime_t *nstime, guint64 nsfiletime);
+/** parse an ISO 8601 format datetime string to nstime, returns number of
+ chars parsed on success, 0 on failure.
+ Note that nstime is set to unset in the case of failure */
+WS_DLL_PUBLIC guint8 iso8601_to_nstime(nstime_t *nstime, const char *ptr);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */