Also:
  * define the leading '+' as a escaped value
  * allow any number of spaces between '+CCLK' and the string value.
---
 src/mm-modem-helpers.c         | 7 +++++--
 src/tests/test-modem-helpers.c | 7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 83a48648..b2806dfa 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -4157,8 +4157,11 @@ mm_parse_cclk_response (const char *response,
 
     g_assert (iso8601p || tzp); /* at least one */
 
-    /* Sample reply: +CCLK: "15/03/05,14:14:26-32" */
-    r = g_regex_new ("[+]CCLK: 
\"(\\d+)/(\\d+)/(\\d+),(\\d+):(\\d+):(\\d+)([-+]\\d+)?\"", 0, 0, NULL);
+    /* Sample replies:
+     *  +CCLK: "15/03/05,14:14:26-32"
+     *  +CCLK: 17/07/26,11:42:15+01
+     */
+    r = g_regex_new 
("\\+CCLK:\\s*\"?(\\d+)/(\\d+)/(\\d+),(\\d+):(\\d+):(\\d+)([-+]\\d+)?\"?", 0, 
0, NULL);
     g_assert (r != NULL);
 
     if (!g_regex_match_full (r, response, -1, 0, 0, &match_info, 
&match_error)) {
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index ca3202ab..16fa62e7 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -3203,6 +3203,13 @@ static const CclkTest cclk_tests[] = {
     { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
         "2015-02-28T20:30:40-08:00", -480 },
 
+    { "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE,
+      "2017-07-26T11:42:15+00:15", 15 },
+    { "+CCLK: 17/07/26,11:42:15+01", TRUE, FALSE, TRUE,
+      "2017-07-26T11:42:15+00:15", 15 },
+    { "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, TRUE,
+      "2017-07-26T11:42:15+00:15", 15 },
+
     { "+CCLK: \"XX/XX/XX,XX:XX:XX+XX\"", FALSE, TRUE, FALSE,
         NULL, MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN },
 
-- 
2.13.1

_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to