diff options
author | Frederic Martinsons <frederic.martinsons@sigfox.com> | 2021-10-15 17:02:20 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-10-22 13:48:20 +0200 |
commit | 9d82d309782c70ed7247db32902f48adebe90669 (patch) | |
tree | bb6a51a909ae9c544d05986c9b9beb96013887df /src | |
parent | 0510e9aef8818eeaa445aea246b670871c671ddb (diff) |
cli, plugins: factorize usage of iso8601 datetime format
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
Includes updates by Aleksander Morgado to fix coding style issues.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-modem-helpers.c | 33 | ||||
-rw-r--r-- | src/mm-modem-helpers.h | 9 | ||||
-rw-r--r-- | src/mm-sms-part-3gpp.c | 1 | ||||
-rw-r--r-- | src/tests/test-modem-helpers.c | 18 | ||||
-rw-r--r-- | src/tests/test-sms-part-3gpp.c | 26 |
5 files changed, 24 insertions, 63 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 1264289c..7c92305a 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -29,6 +29,7 @@ #include <libmm-glib.h> #include "mm-sms-part.h" +#include "mm-common-helpers.h" #include "mm-modem-helpers.h" #include "mm-helper-enums-types.h" #include "mm-log-object.h" @@ -384,38 +385,6 @@ mm_filter_current_bands (const GArray *supported_bands, /*****************************************************************************/ -gchar * -mm_new_iso8601_time (guint year, - guint month, - guint day, - guint hour, - guint minute, - guint second, - gboolean have_offset, - gint offset_minutes) -{ - GString *str; - - str = g_string_sized_new (30); - g_string_append_printf (str, "%04d-%02d-%02dT%02d:%02d:%02d", - year, month, day, hour, minute, second); - if (have_offset) { - if (offset_minutes >=0 ) { - g_string_append_printf (str, "+%02d:%02d", - offset_minutes / 60, - offset_minutes % 60); - } else { - offset_minutes *= -1; - g_string_append_printf (str, "-%02d:%02d", - offset_minutes / 60, - offset_minutes % 60); - } - } - return g_string_free (str, FALSE); -} - -/*****************************************************************************/ - GArray * mm_filter_supported_modes (const GArray *all, const GArray *supported_combinations, diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index 4107137c..98bcea37 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -71,15 +71,6 @@ guint mm_netmask_to_cidr (const gchar *netmask); GArray *mm_filter_current_bands (const GArray *supported_bands, const GArray *current_bands); -gchar *mm_new_iso8601_time (guint year, - guint month, - guint day, - guint hour, - guint minute, - guint second, - gboolean have_offset, - gint offset_minutes); - GArray *mm_filter_supported_modes (const GArray *all, const GArray *supported_combinations, gpointer log_object); diff --git a/src/mm-sms-part-3gpp.c b/src/mm-sms-part-3gpp.c index 51f2cfeb..bfae03a8 100644 --- a/src/mm-sms-part-3gpp.c +++ b/src/mm-sms-part-3gpp.c @@ -23,6 +23,7 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> +#include "mm-common-helpers.h" #include "mm-helper-enums-types.h" #include "mm-sms-part-3gpp.h" #include "mm-charsets.h" diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 9adfc100..1f040e8f 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -3562,25 +3562,25 @@ typedef struct { static const CclkTest cclk_tests[] = { { "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, FALSE, - "2014-08-05T04:00:21+00:00", 0 }, + "2014-08-05T04:00:21Z", 0 }, { "+CCLK: \"14/08/05,04:00:21\"", TRUE, FALSE, TRUE, "2014-08-05T04:00:21+00:00", 0 }, { "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, TRUE, - "2014-08-05T04:00:21+00:00", 0 }, + "2014-08-05T04:00:21Z", 0 }, { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, FALSE, - "2014-08-05T04:00:21+10:00", 600 }, + "2014-08-05T04:00:21+10", 600 }, { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, FALSE, TRUE, "2014-08-05T04:00:21+10:00", 600 }, { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, TRUE, - "2014-08-05T04:00:21+10:00", 600 }, + "2014-08-05T04:00:21+10", 600 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE, - "2015-02-28T20:30:40-08:00", -480 }, + "2015-02-28T20:30:40-08", -480 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE, - "2015-02-28T20:30:40-08:00", -480 }, + "2015-02-28T20:30:40-08", -480 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE, - "2015-02-28T20:30:40-08:00", -480 }, + "2015-02-28T20:30:40-08", -480 }, { "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE, "2017-07-26T11:42:15+00:15", 15 }, @@ -3590,11 +3590,11 @@ static const CclkTest cclk_tests[] = { "2017-07-26T11:42:15+00:15", 15 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE, - "2015-02-28T20:30:40-08:00", -480 }, + "2015-02-28T20:30:40-08", -480 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE, "2015-02-28T20:30:40-08:00", -480 }, { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE, - "2015-02-28T20:30:40-08:00", -480 }, + "2015-02-28T20:30:40-08", -480 }, { "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE, "2017-07-26T11:42:15+00:15", 15 }, diff --git a/src/tests/test-sms-part-3gpp.c b/src/tests/test-sms-part-3gpp.c index db6aa7a0..4da299e7 100644 --- a/src/tests/test-sms-part-3gpp.c +++ b/src/tests/test-sms-part-3gpp.c @@ -119,7 +119,7 @@ test_pdu1 (void) pdu, sizeof (pdu), "+12404492164", /* smsc */ "+16175927198", /* number */ - "2011-02-28T11:50:50-05:00", /* timestamp */ + "2011-02-28T11:50:50-05", /* timestamp */ FALSE, "Here's a longer message [{with some extended characters}] " "thrown in, such as £ and ΩΠΨ and §¿ as well.", /* text */ @@ -140,7 +140,7 @@ test_pdu2 (void) pdu, sizeof (pdu), "+79037011111", /* smsc */ "InternetSMS", /* number */ - "2011-03-29T19:20:04+04:00", /* timestamp */ + "2011-03-29T19:20:04+04", /* timestamp */ FALSE, "тест", /* text */ NULL, 0); @@ -160,7 +160,7 @@ test_pdu3 (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "+18005551212", /* number */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, "hellohello", /* text */ NULL, 0); @@ -181,7 +181,7 @@ test_pdu3_nzpid (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "+18005551212", /* number */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, "hellohello", /* text */ NULL, 0); @@ -202,7 +202,7 @@ test_pdu3_mms (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "+18005551212", /* number */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, "hellohello", /* text */ NULL, 0); @@ -223,7 +223,7 @@ test_pdu3_natl (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "18005551212", /* number, no plus */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, "hellohello", /* text */ NULL, 0); @@ -245,7 +245,7 @@ test_pdu3_8bit (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "+18005551212", /* number */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, NULL, /* text */ expected_data, /* data */ @@ -293,7 +293,7 @@ test_pdu_dcsf1 (void) pdu, sizeof (pdu), "+33609001390", /* smsc */ "1800", /* number */ - "2011-06-24T13:08:15+02:00", /* timestamp */ + "2011-06-24T13:08:15+02", /* timestamp */ FALSE, "Info SFR - Confidentiel, à ne jamais transmettre -\r\n" "Voici votre nouveau mot de passe : sw2ced pour gérer " @@ -317,7 +317,7 @@ test_pdu_dcsf_8bit (void) pdu, sizeof (pdu), "+12345678901", /* smsc */ "+18005551212", /* number */ - "2011-01-01T12:34:56+00:00", /* timestamp */ + "2011-01-01T12:34:56Z", /* timestamp */ FALSE, NULL, /* text */ expected_data, /* data */ @@ -363,7 +363,7 @@ test_pdu_udhi (void) hexpdu, "+31653131316", /* smsc */ "1002", /* number */ - "2011-06-29T23:32:19+02:00", /* timestamp */ + "2011-06-29T23:32:19+02", /* timestamp */ TRUE, "Welkom, bel om uw Voicemail te beluisteren naar +31612001233" " (PrePay: *100*1233#). Voicemail ontvangen is altijd gratis." @@ -388,7 +388,7 @@ test_pdu_multipart (void) hexpdu1, "+12063130025", /* smsc */ "+16175046925", /* number */ - "2012-04-25T19:56:50-04:00", /* timestamp */ + "2012-04-25T19:56:50-04", /* timestamp */ TRUE, /* multipart! */ "This is a very long test designed to exercise multi part capability. It should " "show up as one message, not as two, as the underlying encoding represents ", /* text */ @@ -398,7 +398,7 @@ test_pdu_multipart (void) hexpdu2, "+12063130026", /* smsc */ "+16175046925", /* number */ - "2012-04-25T19:56:51-04:00", /* timestamp */ + "2012-04-25T19:56:51-04", /* timestamp */ TRUE, /* multipart! */ "that the parts are related to one another. ", /* text */ NULL, 0); @@ -431,7 +431,7 @@ test_pdu_not_stored (void) hexpdu1, "+34656000311", /* smsc */ "639337937", /* number */ - "2012-09-11T07:40:36+02:00", /* timestamp */ + "2012-09-11T07:40:36+02", /* timestamp */ FALSE, /* multipart! */ NULL, /* text */ NULL, 0); |