From 9d82d309782c70ed7247db32902f48adebe90669 Mon Sep 17 00:00:00 2001 From: Frederic Martinsons Date: Fri, 15 Oct 2021 17:02:20 +0200 Subject: cli, plugins: factorize usage of iso8601 datetime format Signed-off-by: Frederic Martinsons Includes updates by Aleksander Morgado to fix coding style issues. --- libmm-glib/tests/test-common-helpers.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libmm-glib/tests/test-common-helpers.c') diff --git a/libmm-glib/tests/test-common-helpers.c b/libmm-glib/tests/test-common-helpers.c index 19e1122a..69b95cb1 100644 --- a/libmm-glib/tests/test-common-helpers.c +++ b/libmm-glib/tests/test-common-helpers.c @@ -598,6 +598,24 @@ hexstr_wrong_digits_some (void) common_hexstr2bin_test_failure ("012345k7"); } +static void +date_time_iso8601 (void) +{ + gchar *date = NULL; + + date = mm_new_iso8601_time_from_unix_time (1634307342); + g_assert_cmpstr (date, ==, "2021-10-15T14:15:42Z"); + g_free (date); + + date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, FALSE, 0); + g_assert_cmpstr (date, ==, "2021-10-15T16:15:42Z"); + g_free (date); + + date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, TRUE, 120); + g_assert_cmpstr (date, ==, "2021-10-15T16:15:42+02"); + g_free (date); +} + /**************************************************************/ int main (int argc, char **argv) @@ -644,5 +662,6 @@ int main (int argc, char **argv) g_test_add_func ("/MM/Common/HexStr/wrong-digits-all", hexstr_wrong_digits_all); g_test_add_func ("/MM/Common/HexStr/wrong-digits-some", hexstr_wrong_digits_some); + g_test_add_func ("/MM/Common/DateTime/iso8601", date_time_iso8601); return g_test_run (); } -- cgit v1.2.3-70-g09d2