summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-01-05 19:04:27 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-01-05 19:09:19 +0100
commitf6ba789c3d33bdc1bcc6c00e9660ffbd9f2ba514 (patch)
tree3b1a78e26a482a306df8515d8a4385a095221037
parente88882f0ae031c2c3400a517b751c53a66b1c79f (diff)
downloadweechat-f6ba789c3d33bdc1bcc6c00e9660ffbd9f2ba514.zip
api: add function util_parse_time (issue #649)
-rw-r--r--ChangeLog.adoc2
-rw-r--r--doc/en/weechat_plugin_api.en.adoc34
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc36
-rw-r--r--doc/it/weechat_plugin_api.it.adoc35
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc35
-rw-r--r--doc/sr/weechat_plugin_api.sr.adoc43
-rw-r--r--src/core/wee-util.c237
-rw-r--r--src/core/wee-util.h1
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/weechat-plugin.h5
-rw-r--r--tests/unit/core/test-core-util.cpp112
11 files changed, 534 insertions, 7 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 0ae88b6fe..1705fca1f 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -27,7 +27,7 @@ New features::
* core: display only version with command `/version`, add options `-o` and `-ol` in command `/upgrade`
* core: add number of processes in command `/sys waitpid`
* core, alias, trigger: allow wildcard in commands `/bar`, `/item`, `/proxy`, `/alias` and `/trigger` (issue #1956)
- * api: add functions util_strftimeval, printf_datetime_tags, printf_y_datetime_tags (issue #649)
+ * api: add functions util_strftimeval, util_parse_time, printf_datetime_tags, printf_y_datetime_tags (issue #649)
* api: add argument "date_usec" in hook_print callback (issue #649)
* api: add property "type" in function buffer_get_string
* api: add info "mouse"
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 403f9b8d6..70f1dd3eb 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -4737,6 +4737,40 @@ weechat_util_strftimeval (time, sizeof (time), "%FT%T.%f", &tv);
[NOTE]
This function is not available in scripting API.
+==== util_parse_time
+
+_WeeChat ≥ 4.2.0._
+
+Parse date/time with support of microseconds.
+
+Prototype:
+
+[source,c]
+----
+int util_parse_time (const char *datetime, struct timeval *tv);
+----
+
+Arguments:
+
+* _date_: date/time
+* _tv_: parsed date/time ("timeval" structure)
+
+Return value:
+
+* 1 if OK, 0 if error
+
+C example:
+
+[source,c]
+----
+struct timeval tv;
+weechat_util_parse_time ("2023-12-25T10:29:09.456789Z", &tv); /* == 1 */
+/* result: tv.tv_sec == 1703500149, tv.tv_usec = 456789 */
+----
+
+[NOTE]
+This function is not available in scripting API.
+
==== util_version_number
_WeeChat ≥ 0.3.9._
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 83553bef1..191459d81 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -4818,6 +4818,40 @@ weechat_util_strftimeval (time, sizeof (time), "%FT%T.%f", &tv);
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
+==== util_parse_time
+
+_WeeChat ≥ 4.2.0._
+
+Analyser la date/heure avec le support des microsecondes.
+
+Prototype :
+
+[source,c]
+----
+int util_parse_time (const char *datetime, struct timeval *tv);
+----
+
+Paramètres :
+
+* _date_ : date/heure
+* _tv_: date/heure analysée (structure "timeval")
+
+Valeur de retour :
+
+* 1 si OK, 0 si erreur
+
+Exemple en C :
+
+[source,c]
+----
+struct timeval tv;
+weechat_util_parse_time ("2023-12-25T10:29:09.456789Z", &tv); /* == 1 */
+/* result: tv.tv_sec == 1703500149, tv.tv_usec = 456789 */
+----
+
+[NOTE]
+Cette fonction n'est pas disponible dans l'API script.
+
==== util_version_number
_WeeChat ≥ 0.3.9._
@@ -5756,7 +5790,7 @@ Paramètres :
Valeur de retour :
-* 1 if OK, 0 if error
+* 1 si OK, 0 si erreur
Exemple en C :
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index 0646e16f2..48d738838 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -4955,6 +4955,41 @@ weechat_util_strftimeval (time, sizeof (time), "%FT%T.%f", &tv);
[NOTE]
Questa funzione non è disponibile nelle API per lo scripting.
+// TRANSLATION MISSING
+==== util_parse_time
+
+_WeeChat ≥ 4.2.0._
+
+Parse date/time with support of microseconds.
+
+Prototype:
+
+[source,c]
+----
+int util_parse_time (const char *datetime, struct timeval *tv);
+----
+
+Arguments:
+
+* _date_: date/time
+* _tv_: parsed date/time ("timeval" structure)
+
+Return value:
+
+* 1 if OK, 0 if error
+
+C example:
+
+[source,c]
+----
+struct timeval tv;
+weechat_util_parse_time ("2023-12-25T10:29:09.456789Z", &tv); /* == 1 */
+/* result: tv.tv_sec == 1703500149, tv.tv_usec = 456789 */
+----
+
+[NOTE]
+Questa funzione non è disponibile nelle API per lo scripting.
+
==== util_version_number
_WeeChat ≥ 0.3.9._
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index aa42991be..d88783bec 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -4862,6 +4862,41 @@ weechat_util_strftimeval (time, sizeof (time), "%FT%T.%f", &tv);
[NOTE]
スクリプト API ではこの関数を利用できません。
+// TRANSLATION MISSING
+==== util_parse_time
+
+_WeeChat ≥ 4.2.0._
+
+Parse date/time with support of microseconds.
+
+Prototype:
+
+[source,c]
+----
+int util_parse_time (const char *datetime, struct timeval *tv);
+----
+
+Arguments:
+
+* _date_: date/time
+* _tv_: parsed date/time ("timeval" structure)
+
+Return value:
+
+* 1 if OK, 0 if error
+
+C example:
+
+[source,c]
+----
+struct timeval tv;
+weechat_util_parse_time ("2023-12-25T10:29:09.456789Z", &tv); /* == 1 */
+/* result: tv.tv_sec == 1703500149, tv.tv_usec = 456789 */
+----
+
+[NOTE]
+スクリプト API ではこの関数を利用できません。
+
==== util_version_number
_WeeChat バージョン 0.3.9 以上で利用可。_
diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc
index 995eca75c..30b8ed48b 100644
--- a/doc/sr/weechat_plugin_api.sr.adoc
+++ b/doc/sr/weechat_plugin_api.sr.adoc
@@ -4565,14 +4565,14 @@ _WeeChat ≥ 4.2.0._
Format date and time like function `strftime` in C library, using `struct timeval`
as input, and supporting extra specifiers for microseconds.
-Prototype:
+Прототип:
[source,c]
----
int weechat_util_strftimeval (char *string, int max, const char *format, struct timeval *tv);
----
-Arguments:
+Аргументи:
* _string_: buffer where the formatted string is stored
* _max_: string size
@@ -4581,11 +4581,11 @@ Arguments:
(for example `%.3` for milliseconds)
** `%f`: alias of `%.6`
-Return value:
+Повратна вредност:
* number of bytes put in _string_ (value returned from _strftime_ function)
-C example:
+C пример:
[source,c]
----
@@ -4599,6 +4599,41 @@ weechat_util_strftimeval (time, sizeof (time), "%FT%T.%f", &tv);
[NOTE]
Ова функција није доступна у API скриптовања.
+// TRANSLATION MISSING
+==== util_parse_time
+
+_WeeChat ≥ 4.2.0._
+
+Parse date/time with support of microseconds.
+
+Прототип:
+
+[source,c]
+----
+int util_parse_time (const char *datetime, struct timeval *tv);
+----
+
+Аргументи:
+
+* _date_: date/time
+* _tv_: parsed date/time ("timeval" structure)
+
+Повратна вредност:
+
+* 1 if OK, 0 if error
+
+C пример:
+
+[source,c]
+----
+struct timeval tv;
+weechat_util_parse_time ("2023-12-25T10:29:09.456789Z", &tv); /* == 1 */
+/* result: tv.tv_sec == 1703500149, tv.tv_usec = 456789 */
+----
+
+[NOTE]
+Ова функција није доступна у API скриптовања.
+
==== util_version_number
_WeeChat ≥ 0.3.9._
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index b885a9e00..abd149ae1 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -237,6 +237,243 @@ util_strftimeval (char *string, int max, const char *format, struct timeval *tv)
}
/*
+ * Parses a date/time string, which can be one of these formats:
+ * "2024-01-04" -> date at midnight
+ * "2024-01-04T22:01:02" -> ISO 8601, local time
+ * "2024-01-04T22:01:02.123" -> ISO 8601, local time, with milliseconds
+ * "2024-01-04T22:01:02.123456" -> ISO 8601, local time, with microseconds
+ * "2024-01-04T21:01:02Z" -> ISO 8601, UTC
+ * "2024-01-04T21:01:02.123Z" -> ISO 8601, UTC, with milliseconds
+ * "2024-01-04T21:01:02.123456Z" -> ISO 8601, UTC, with microseconds
+ * "22:01:02" -> current date, local time
+ * "22:01:02.123" -> current date, local time with milliseconds
+ * "22.01:02.123456" -> current date, local time with microseconds
+ * "21:01:02Z" -> current date, UTC
+ * "21:01:02.123Z" -> current date, UTC, with milliseconds
+ * "21.01:02.123456Z" -> current date, UTC, with microseconds
+ * "1704402062" -> timestamp date
+ * "1704402062.123" -> timestamp date, with milliseconds
+ * "1704402062,123" -> timestamp date, with milliseconds
+ * "1704402062.123456" -> timestamp date, with microseconds
+ * "1704402062,123456" -> timestamp date, with microseconds
+ *
+ * Returns:
+ * 1: OK
+ * 0: error
+ */
+
+int
+util_parse_time (const char *datetime, struct timeval *tv)
+{
+ char *string, *pos, *pos2, str_usec[16], *error, str_date[128];
+ struct tm tm_date, tm_date_gm, tm_date_local, *local_time;
+ time_t time_now, time_gm, time_local;
+ long value;
+ int rc, length, use_local_time, timezone_offset, offset_factor, hour, min;
+
+ if (!datetime || !datetime[0] || !tv)
+ return 0;
+
+ rc = 0;
+
+ tv->tv_sec = 0;
+ tv->tv_usec = 0;
+
+ use_local_time = 1;
+ timezone_offset = 0;
+ offset_factor = 1;
+
+ string = strdup (datetime);
+ if (!string)
+ return 0;
+
+ /* extract microseconds and remove them from string2 */
+ pos = strchr (string, '.');
+ if (!pos)
+ pos = strchr (string, ',');
+ if (pos)
+ {
+ pos2 = pos + 1;
+ while (isdigit ((unsigned char)pos2[0]))
+ {
+ pos2++;
+ }
+ length = pos2 - pos - 1;
+ if (length > 0)
+ {
+ if (length > 6)
+ length = 6;
+ memcpy (str_usec, pos + 1, length);
+ str_usec[length] = '\0';
+ while (strlen (str_usec) < 6)
+ {
+ strcat (str_usec, "0");
+ }
+ error = NULL;
+ value = strtol (str_usec, &error, 10);
+ if (error && !error[0])
+ {
+ if (value < 0)
+ value = 0;
+ else if (value > 999999)
+ value = 999999;
+ tv->tv_usec = (int)value;
+ }
+ }
+ memmove (pos, pos2, strlen (pos2) + 1);
+ }
+
+ /* extract timezone and remove it from string2 */
+ pos = strchr (string, 'Z');
+ if (pos)
+ {
+ pos[0] = '\0';
+ use_local_time = 0;
+ timezone_offset = 0;
+ }
+ else
+ {
+ pos = strchr (string, 'T');
+ if (pos)
+ {
+ pos2 = strchr (pos, '+');
+ if (pos2)
+ {
+ pos2[0] = '\0';
+ pos2++;
+ offset_factor = 1;
+ }
+ else
+ {
+ pos2 = strchr (pos, '-');
+ if (pos2)
+ {
+ pos2[0] = '\0';
+ pos2++;
+ offset_factor = -1;
+ }
+ }
+ if (pos2)
+ {
+ use_local_time = 0;
+ hour = 0;
+ min = 0;
+ if (isdigit ((unsigned char)pos2[0])
+ && isdigit ((unsigned char)pos2[1]))
+ {
+ hour = ((pos2[0] - '0') * 10) + (pos2[1] - '0');
+ pos2 += 2;
+ if (pos2[0] == ':')
+ pos2++;
+ if (isdigit ((unsigned char)pos2[0])
+ && isdigit ((unsigned char)pos2[1]))
+ {
+ min = ((pos2[0] - '0') * 10) + (pos2[1] - '0');
+ }
+ }
+ timezone_offset = offset_factor * ((hour * 3600) + (min * 60));
+ }
+ }
+ }
+
+ if (strchr (string, '-'))
+ {
+ if (strchr (string, ':'))
+ {
+ /* ISO 8601 format like: "2024-01-04T21:01:02.123Z" */
+ /* initialize structure, because strptime does not do it */
+ memset (&tm_date, 0, sizeof (struct tm));
+ pos = strptime (string, "%Y-%m-%dT%H:%M:%S", &tm_date);
+ if (pos && (tm_date.tm_year > 0))
+ {
+ if (use_local_time)
+ {
+ tv->tv_sec = mktime (&tm_date);
+ }
+ else
+ {
+ /* convert to UTC and add timezone_offset */
+ time_now = mktime (&tm_date);
+ gmtime_r (&time_now, &tm_date_gm);
+ localtime_r (&time_now, &tm_date_local);
+ time_gm = mktime (&tm_date_gm);
+ time_local = mktime (&tm_date_local);
+ tv->tv_sec = mktime (&tm_date_local)
+ + (time_local - time_gm)
+ + timezone_offset;
+ }
+ rc = 1;
+ }
+ }
+ else
+ {
+ /* ISO 8601 format like: "2024-01-04" */
+ /* initialize structure, because strptime does not do it */
+ memset (&tm_date, 0, sizeof (struct tm));
+ pos = strptime (string, "%Y-%m-%d", &tm_date);
+ if (pos && (tm_date.tm_year > 0))
+ {
+ tv->tv_sec = mktime (&tm_date);
+ rc = 1;
+ }
+ }
+ }
+ else if (strchr (string, ':'))
+ {
+ /* hour format like: "21:01:02" */
+ time_now = time (NULL);
+ local_time = localtime (&time_now);
+ strftime (str_date, sizeof (str_date),
+ "%Y-%m-%dT", local_time);
+ strcat (str_date, string);
+ /* initialize structure, because strptime does not do it */
+ memset (&tm_date, 0, sizeof (struct tm));
+ pos = strptime (str_date, "%Y-%m-%dT%H:%M:%S", &tm_date);
+ if (pos)
+ {
+ if (use_local_time)
+ {
+ tv->tv_sec = mktime (&tm_date);
+ }
+ else
+ {
+ /* convert to UTC and add timezone_offset */
+ time_now = mktime (&tm_date);
+ gmtime_r (&time_now, &tm_date_gm);
+ localtime_r (&time_now, &tm_date_local);
+ time_gm = mktime (&tm_date_gm);
+ time_local = mktime (&tm_date_local);
+ tv->tv_sec = mktime (&tm_date_local)
+ + (time_local - time_gm)
+ + timezone_offset;
+ }
+ rc = 1;
+ }
+ }
+ else
+ {
+ /* timestamp format: "1704402062" */
+ error = NULL;
+ value = strtol (string, &error, 10);
+ if (error && !error[0] && (value >= 0))
+ {
+ tv->tv_sec = (time_t)value;
+ rc = 1;
+ }
+ }
+
+ free (string);
+
+ if (!rc)
+ {
+ tv->tv_sec = 0;
+ tv->tv_usec = 0;
+ }
+
+ return rc;
+}
+
+/*
* Returns difference between two times.
*
* The following variables are set, if pointer is not NULL:
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index e67550c3f..75cdf6800 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -33,6 +33,7 @@ extern char *util_get_microseconds_string (long long diff);
extern const char *util_get_time_string (const time_t *date);
extern int util_strftimeval (char *string, int max, const char *format,
struct timeval *tv);
+extern int util_parse_time (const char *datetime, struct timeval *tv);
extern void util_get_time_diff (time_t time1, time_t time2,
time_t *total_seconds,
int *days, int *hours, int *minutes,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 1a7be2737..12edccb3f 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -695,6 +695,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->util_timeval_add = &util_timeval_add;
new_plugin->util_get_time_string = &util_get_time_string;
new_plugin->util_strftimeval = &util_strftimeval;
+ new_plugin->util_parse_time = &util_parse_time;
new_plugin->util_version_number = &util_version_number;
new_plugin->list_new = &weelist_new;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 6647494e0..ad45ebe5c 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -68,7 +68,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20231226-01"
+#define WEECHAT_PLUGIN_API_VERSION "20240105-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -439,6 +439,7 @@ struct t_weechat_plugin
const char *(*util_get_time_string) (const time_t *date);
int (*util_strftimeval) (char *string, int max, const char *format,
struct timeval *tv);
+ int (*util_parse_time) (const char *datetime, struct timeval *tv);
int (*util_version_number) (const char *version);
/* sorted lists */
@@ -1499,6 +1500,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->util_get_time_string)(__date)
#define weechat_util_strftimeval(__string, __max, __format, __tv) \
(weechat_plugin->util_strftimeval)(__string, __max, __format, __tv)
+#define weechat_util_parse_time(__datetime, __tv) \
+ (weechat_plugin->util_parse_time)(__datetime, __tv)
#define weechat_util_version_number(__version) \
(weechat_plugin->util_version_number)(__version)
diff --git a/tests/unit/core/test-core-util.cpp b/tests/unit/core/test-core-util.cpp
index a587274a6..a7fc00e9d 100644
--- a/tests/unit/core/test-core-util.cpp
+++ b/tests/unit/core/test-core-util.cpp
@@ -25,14 +25,23 @@
extern "C"
{
+#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include <sys/time.h>
#include "src/core/wee-string.h"
#include "src/core/wee-util.h"
}
+#define WEE_PARSE_DATE(__result, __sec, __usec, __datetime) \
+ tv.tv_sec = 0; \
+ tv.tv_usec = 0; \
+ LONGS_EQUAL(__result, util_parse_time (__datetime, &tv)); \
+ LONGS_EQUAL(__sec, tv.tv_sec); \
+ LONGS_EQUAL(__usec, tv.tv_usec);
+
TEST_GROUP(CoreUtil)
{
};
@@ -231,6 +240,109 @@ TEST(CoreUtil, Strftimeval)
/*
* Tests functions:
+ * util_parse_time
+ */
+
+TEST(CoreUtil, ParseTime)
+{
+ struct timeval tv;
+ struct tm *local_time;
+ time_t date;
+ char str_time[128];
+
+ /* test with local timezone: UTC+1 */
+ setenv ("TZ", "UTC+1", 1);
+
+ LONGS_EQUAL(0, util_parse_time (NULL, NULL));
+ LONGS_EQUAL(0, util_parse_time (NULL, &tv));
+
+ WEE_PARSE_DATE(0, 0, 0, "");
+ WEE_PARSE_DATE(0, 0, 0, "invalid");
+
+ /*
+ * expected: 2023-12-25T00:00:00Z == 1703462400
+ * (local timezone UTC+1: 1703466000)
+ */
+ WEE_PARSE_DATE(1, 1703466000, 0, "2023-12-25");
+
+ /* expected: current date with specified local time */
+ date = time (NULL);
+ local_time = localtime (&date);
+ strftime (str_time, sizeof (str_time), "%H:%M:%S", local_time);
+ LONGS_EQUAL(1, util_parse_time (str_time, &tv));
+ CHECK((tv.tv_sec >= date) && (tv.tv_sec <= date + 10));
+ LONGS_EQUAL(0, tv.tv_usec);
+
+ date = time (NULL);
+ local_time = localtime (&date);
+ strftime (str_time, sizeof (str_time), "%H:%M:%S.456789", local_time);
+ LONGS_EQUAL(1, util_parse_time (str_time, &tv));
+ CHECK((tv.tv_sec >= date) && (tv.tv_sec <= date + 10));
+ LONGS_EQUAL(456789, tv.tv_usec);
+
+ /* expected: current date with specified UTC time */
+ date = time (NULL);
+ local_time = localtime (&date);
+ strftime (str_time, sizeof (str_time), "%H:%M:%SZ", local_time);
+ LONGS_EQUAL(1, util_parse_time (str_time, &tv));
+ CHECK((tv.tv_sec >= date - 3600) && (tv.tv_sec <= date - 3600 + 10));
+ LONGS_EQUAL(0, tv.tv_usec);
+
+ date = time (NULL);
+ local_time = localtime (&date);
+ strftime (str_time, sizeof (str_time), "%H:%M:%S.456789Z", local_time);
+ LONGS_EQUAL(1, util_parse_time (str_time, &tv));
+ CHECK((tv.tv_sec >= date - 3600) && (tv.tv_sec <= date - 3600 + 10));
+ LONGS_EQUAL(456789, tv.tv_usec);
+
+ /*
+ * expected: 2023-12-25T10:29:09.456789Z == 1703500149.456789
+ * (local timezone UTC+1: 1703503749.456789)
+ */
+ WEE_PARSE_DATE(1, 1703500149 + 3600, 0, "2023-12-25T10:29:09");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09Z");
+ WEE_PARSE_DATE(1, 1703500149, 456000, "2023-12-25T10:29:09.456Z");
+ WEE_PARSE_DATE(1, 1703500149, 456789, "2023-12-25T10:29:09.456789Z");
+
+ /*
+ * expected: 2023-12-25T10:29:09.456789Z == 1703500149.456789
+ * with timezone offset
+ */
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09+00");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09+0000");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09+00:00");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09-00");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09-0000");
+ WEE_PARSE_DATE(1, 1703500149, 0, "2023-12-25T10:29:09-00:00");
+ WEE_PARSE_DATE(1, 1703500149, 456789, "2023-12-25T10:29:09.456789-00:00");
+
+ WEE_PARSE_DATE(1, 1703500149 + 7200, 0, "2023-12-25T10:29:09+02");
+ WEE_PARSE_DATE(1, 1703500149 + 60, 0, "2023-12-25T10:29:09+0001");
+ WEE_PARSE_DATE(1, 1703500149 + 60, 456789, "2023-12-25T10:29:09.456789+0001");
+
+ WEE_PARSE_DATE(1, 1703500149 + 7200, 0, "2023-12-25T10:29:09+0200");
+ WEE_PARSE_DATE(1, 1703500149 + 7200, 0, "2023-12-25T10:29:09+02:00");
+ WEE_PARSE_DATE(1, 1703500149 + 3600 + 1800, 0, "2023-12-25T10:29:09+0130");
+ WEE_PARSE_DATE(1, 1703500149 + 3600 + 1800, 0, "2023-12-25T10:29:09+01:30");
+ WEE_PARSE_DATE(1, 1703500149 + 3600 + 1800, 456789, "2023-12-25T10:29:09.456789+01:30");
+
+ WEE_PARSE_DATE(1, 1703500149 - 60, 0, "2023-12-25T10:29:09-0001");
+ WEE_PARSE_DATE(1, 1703500149 - 3600 - 1800, 0, "2023-12-25T10:29:09-0130");
+ WEE_PARSE_DATE(1, 1703500149 - 3600 - 1800, 0, "2023-12-25T10:29:09-01:30");
+ WEE_PARSE_DATE(1, 1703500149 - 3600 - 1800, 456789, "2023-12-25T10:29:09.456789-01:30");
+
+ /* expected: 2023-12-25T10:29:09.456789Z == 1703500149.456789 */
+ WEE_PARSE_DATE(1, 1703500149, 0, "1703500149");
+ WEE_PARSE_DATE(1, 1703500149, 456000, "1703500149.456");
+ WEE_PARSE_DATE(1, 1703500149, 456789, "1703500149.456789");
+ WEE_PARSE_DATE(1, 1703500149, 456000, "1703500149,456");
+ WEE_PARSE_DATE(1, 1703500149, 456789, "1703500149,456789");
+
+ setenv ("TZ", "", 1);
+}
+
+/*
+ * Tests functions:
* util_get_time_diff
*/