diff options
author | Dan Williams <dcbw@redhat.com> | 2013-04-24 14:46:23 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-04-25 15:14:14 -0500 |
commit | 2e8866c8b74c50c3c5318b13cfc78530a6130c41 (patch) | |
tree | 3a2ddd5f913952ce12089c55521921ebab77505d /src | |
parent | 7d3a4aba4fb0f7920e40f88836698a0a10bc7e3c (diff) |
time: normalize GetNetworkTime() response to local time + timezone info (bgo #697372)
The GetNetworkTime() response is defined to be an ISO8601 string, which
is in turn defined to be in local time. Make sure that's reflected in
the documentation, and append the timezone offset to UTC where we have
it.
Oddly, Icera devices return their time info in UTC with an offset to
the local timezone, so we have to jump through some hoops there to
convert the response to localtime based on the reported offset.
Some additional fixes by Aleksander Morgado <aleksander@lanedo.com>.
https://bugzilla.gnome.org/show_bug.cgi?id=697372
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-modem-helpers.c | 32 | ||||
-rw-r--r-- | src/mm-modem-helpers.h | 9 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 09bb71d7..44a00a53 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -216,6 +216,38 @@ 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); +} + +/*****************************************************************************/ + /* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */ #define CREG1 "\\+(CREG|CGREG|CEREG):\\s*0*([0-9])" diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index eb02337e..5a8ba493 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -64,6 +64,15 @@ 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); + /*****************************************************************************/ /* 3GPP specific helpers and utilities */ /*****************************************************************************/ |