[glib] Initialise variable in g_time_val_from_iso8601()
- From: Javier Jardón <jjardon src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Initialise variable in g_time_val_from_iso8601()
- Date: Wed, 2 Dec 2009 00:52:46 +0000 (UTC)
commit 2321e5aed07154761223bb124770beba56700e41
Author: Matthew W. S. Bell <matthew bells23 org uk>
Date: Wed Dec 2 01:48:30 2009 +0100
Initialise variable in g_time_val_from_iso8601()
The function does not initialise the struct tm,
giving it improper values of tm_isdst making the result
an hour out.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=603540
glib/gtimer.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/glib/gtimer.c b/glib/gtimer.c
index 407ce85..cd6a082 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -301,7 +301,7 @@ gboolean
g_time_val_from_iso8601 (const gchar *iso_date,
GTimeVal *time_)
{
- struct tm tm;
+ struct tm tm = {0};
long val;
g_return_val_if_fail (iso_date != NULL, FALSE);
@@ -328,7 +328,7 @@ g_time_val_from_iso8601 (const gchar *iso_date,
tm.tm_mon = strtoul (iso_date, (char **)&iso_date, 10) - 1;
if (*iso_date++ != '-')
- return FALSE;
+ return FALSE;
tm.tm_mday = strtoul (iso_date, (char **)&iso_date, 10);
}
@@ -390,7 +390,7 @@ g_time_val_from_iso8601 (const gchar *iso_date,
val = strtoul (iso_date + 1, (char **)&iso_date, 10);
if (*iso_date == ':')
- val = 60 * val + strtoul (iso_date + 1, (char **)&iso_date, 10);
+ val = 60 * val + strtoul (iso_date + 1, (char **)&iso_date, 10);
else
val = 60 * (val / 100) + (val % 100);
@@ -399,6 +399,7 @@ g_time_val_from_iso8601 (const gchar *iso_date,
else
{
/* No "Z" or offset, so local time */
+ tm.tm_isdst = -1; /* locale selects DST */
time_->tv_sec = mktime (&tm);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]