[Openvas-commits] r12149 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Nov 21 17:29:31 CET 2011
Author: mattm
Date: 2011-11-21 17:29:29 +0100 (Mon, 21 Nov 2011)
New Revision: 12149
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage_sql.c
Log:
* src/manage_sql.c (parse_ctime): Parse ctime using the current timezone.
(parse_iso_time): Call parse_ctime instead of parse_iso_time, so that old
reports are imported using the current timezone.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2011-11-21 15:11:05 UTC (rev 12148)
+++ trunk/openvas-manager/ChangeLog 2011-11-21 16:29:29 UTC (rev 12149)
@@ -1,5 +1,11 @@
-2011-11-18 Matthew Mundell <matthew.mundell at greenbone.net>
+2011-11-21 Matthew Mundell <matthew.mundell at greenbone.net>
+ * src/manage_sql.c (parse_ctime): Parse ctime using the current timezone.
+ (parse_iso_time): Call parse_ctime instead of parse_iso_time, so that old
+ reports are imported using the current timezone.
+
+2011-11-21 Matthew Mundell <matthew.mundell at greenbone.net>
+
Switch report times to ISO 8601 format.
* src/manage_sql.c (ctime_strip_newline): Remove. Out of use.
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2011-11-21 15:11:05 UTC (rev 12148)
+++ trunk/openvas-manager/src/manage_sql.c 2011-11-21 16:29:29 UTC (rev 12149)
@@ -1247,6 +1247,8 @@
/**
* @brief Convert an OTP time into seconds since epoch.
*
+ * Use UTC as timezone.
+ *
* @param[in] text_time Time as text in ctime format.
*
* @return Time since epoch.
@@ -1305,6 +1307,38 @@
}
/**
+ * @brief Convert a ctime into seconds since epoch.
+ *
+ * Use the current timezone.
+ *
+ * @param[in] text_time Time as text in ctime format.
+ *
+ * @return Time since epoch.
+ */
+static int
+parse_ctime (const char *text_time)
+{
+ int epoch_time;
+ struct tm tm;
+
+ /* ctime format: "Wed Jun 30 21:49:08 1993". */
+
+ if (strptime ((char*) text_time, "%a %b %d %H:%M:%S %Y", &tm) == NULL)
+ {
+ g_warning ("%s: Failed to parse time", __FUNCTION__);
+ return 0;
+ }
+ epoch_time = mktime (&tm);
+ if (epoch_time == -1)
+ {
+ g_warning ("%s: Failed to make time", __FUNCTION__);
+ return 0;
+ }
+
+ return epoch_time;
+}
+
+/**
* @brief Convert an ISO time into seconds since epoch.
*
* For backward compatibility, if the conversion fails try parse in ctime
@@ -1322,7 +1356,7 @@
if (strptime ((char*) text_time, "%FT%T%z", &tm) == NULL)
{
- return parse_otp_time (text_time);
+ return parse_ctime (text_time);
}
epoch_time = mktime (&tm);
More information about the Openvas-commits
mailing list