[libgda] libgda: gda_parse_iso8601_timestamp removed



commit 6ab6c1240790a120f86f633fe6f54864c739b8f5
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Fri Jun 12 22:21:17 2020 -0500

    libgda: gda_parse_iso8601_timestamp removed
    
    g_date_time_new_from_iso8601() should be used instead.
    
    For details, see https://gitlab.gnome.org/GNOME/libgda/-/issues/207

 doc/C/libgda/libgda-6.0-sections.txt        |  1 -
 libgda/gda-util.c                           | 21 +--------------------
 libgda/gda-util.h                           |  1 -
 libgda/gda-value.c                          |  2 +-
 libgda/sqlite/gda-sqlite-recordset.c        |  6 ++++--
 libgda/sqlite/virtual/gda-vconnection-hub.c |  4 +++-
 tests/test-input-parsers.c                  |  4 ++--
 7 files changed, 11 insertions(+), 28 deletions(-)
---
diff --git a/doc/C/libgda/libgda-6.0-sections.txt b/doc/C/libgda/libgda-6.0-sections.txt
index df3fa9ef2..22ebd62d5 100644
--- a/doc/C/libgda/libgda-6.0-sections.txt
+++ b/doc/C/libgda/libgda-6.0-sections.txt
@@ -954,7 +954,6 @@ gda_connection_string_split
 <SUBSECTION>
 gda_parse_iso8601_date
 gda_parse_iso8601_time
-gda_parse_iso8601_timestamp
 gda_parse_formatted_date
 gda_parse_formatted_time
 gda_parse_formatted_timestamp
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index 7d49a0daf..cdb4380f0 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -3314,25 +3314,6 @@ gda_parse_formatted_time (const gchar *value, gchar sep)
        return _parse_iso8601_time (value, sep, 0, &endptr);
 }
 
-/**
- * gda_parse_iso8601_timestamp:
- * @value: a string
- *
- * Extracts date and time parts from @value, and sets @timestamp's contents
- *
- * Accepted date format is "YYYY-MM-DDTHH:MM:SS[.ms][TZ]" where TZ is +hour or -hour
- *
- * Returns: (transfer full): a new #GDateTime if @value has been successfully parsed as a valid timestamp 
(see g_date_valid()). The returned instance should be freed using g_date_time_unref().
- */
-GDateTime*
-gda_parse_iso8601_timestamp (const gchar *value)
-{
-  GTimeZone *tz = g_time_zone_new_utc ();
-  GDateTime *dt = g_date_time_new_from_iso8601 (value,tz);
-  g_time_zone_unref (tz);
-  return dt;
-}
-
 /**
  * gda_parse_formatted_timestamp:
  * @value: a string to be parsed
@@ -3341,7 +3322,7 @@ gda_parse_iso8601_timestamp (const gchar *value)
  * @third: a #GDateDMY specifying which of year, month or day appears third (in the first bytes) in @value
  * @sep: specifies the expected separator character between year, month and day (for example '-')
  *
- * This function is similar to gda_parse_iso8601_timestamp() (with @first being @G_DATE_YEAR, @second being 
@G_DATE_MONTH,
+ * This function is similar to g_date_time_new_from_iso8601() (with @first being @G_DATE_YEAR, @second being 
@G_DATE_MONTH,
  * @third being @G_DATE_DAY and @sep being '-') but allows one to specify the expected date format.
  *
  * Returns: (nullable) (transfer full): a new #GDateTime if @value has been successfully parsed as a valid 
date (see g_date_valid()).
diff --git a/libgda/gda-util.h b/libgda/gda-util.h
index 1000fce55..fdffad9cf 100644
--- a/libgda/gda-util.h
+++ b/libgda/gda-util.h
@@ -120,7 +120,6 @@ void         gda_connection_string_split (const gchar *string, gchar **out_cnc_p
 gboolean     gda_parse_iso8601_date (GDate *gdate, const gchar *value);
 GdaTime     *gda_parse_iso8601_time (const gchar *value);
 
-GDateTime    *gda_parse_iso8601_timestamp (const gchar *value);
 gboolean     gda_parse_formatted_date (GDate *gdate, const gchar *value,
                                       GDateDMY first, GDateDMY second, GDateDMY third, gchar sep);
 GdaTime     *gda_parse_formatted_time (const gchar *value, gchar sep);
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 49c2e3fc4..2a38548c2 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -2623,7 +2623,7 @@ gda_value_set_timestamp (GValue *value, const GDateTime *val)
  *   <listitem><para>numerical types: C locale format (dot as a fraction separator)</para></listitem>
  *   <listitem><para>G_TYPE_DATE: see <link 
linkend="gda-parse-iso8601-date">gda_parse_iso8601_date()</link></para></listitem>
  *   <listitem><para>GDA_TYPE_TIME: see <link 
linkend="gda-parse-iso8601-time">gda_parse_iso8601_time()</link></para></listitem>
- *   <listitem><para>GDA_TYPE_TIMESTAMP: see <link 
linkend="gda-parse-iso8601-timestamp">gda_parse_iso8601_timestamp()</link></para></listitem>
+ *   <listitem><para>GDA_TYPE_TIMESTAMP: see <link 
linkend="g-date-time-new-iso8601">g_date_time_new_from_iso8601()</link></para></listitem>
  * </itemizedlist>
  *
  * This function is typically used when reading configuration files or other non-user input that should be 
locale
diff --git a/libgda/sqlite/gda-sqlite-recordset.c b/libgda/sqlite/gda-sqlite-recordset.c
index 1015f8be8..4eca7f862 100644
--- a/libgda/sqlite/gda-sqlite-recordset.c
+++ b/libgda/sqlite/gda-sqlite-recordset.c
@@ -544,9 +544,11 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                        }
                                }
                                else if (g_type_is_a (type, G_TYPE_DATE_TIME)) {
-                                       GDateTime* timestamp = gda_parse_iso8601_timestamp (
+                                   GTimeZone *tz = g_time_zone_new_utc ();
+                                       GDateTime* timestamp = g_date_time_new_from_iso8601 (
                                                                          (gchar *) SQLITE3_CALL (prov, 
sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
-                                                                               real_col));
+                                                                               real_col), tz);
+                                       g_time_zone_unref (tz);
                                        if (timestamp == NULL) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
diff --git a/libgda/sqlite/virtual/gda-vconnection-hub.c b/libgda/sqlite/virtual/gda-vconnection-hub.c
index c25a7b2ed..475063bed 100644
--- a/libgda/sqlite/virtual/gda-vconnection-hub.c
+++ b/libgda/sqlite/virtual/gda-vconnection-hub.c
@@ -677,7 +677,9 @@ create_value_from_sqlite3_gvalue (GType type, GValue *svalue, GError **error)
                if (!g_type_is_a (G_VALUE_TYPE (svalue), G_TYPE_STRING))
                        allok = FALSE;
                else {
-                       GDateTime* timestamp = gda_parse_iso8601_timestamp (g_value_get_string (svalue));
+                   GTimeZone *tz = g_time_zone_new_utc ();
+                       GDateTime* timestamp = g_date_time_new_from_iso8601 (g_value_get_string (svalue), tz);
+                       g_time_zone_unref (tz);
                        if (timestamp == NULL) {
                                g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
                                             GDA_SERVER_PROVIDER_DATA_ERROR,
diff --git a/tests/test-input-parsers.c b/tests/test-input-parsers.c
index 23ee3d6a8..36c4ca5ff 100644
--- a/tests/test-input-parsers.c
+++ b/tests/test-input-parsers.c
@@ -198,7 +198,7 @@ test_parse_iso8601_timestamp (void)
 
                        GDateTime* timestamp = g_date_time_new_from_iso8601 (str, NULL);
                        if (timestamp == NULL && td.exp_retval && tt.exp_retval) {
-                               g_print ("test_parse_iso8601: Wrong result for gda_parse_iso8601_timestamp 
(\"%s\"): for valid timestamp\n",
+                               g_print ("test_parse_iso8601: Wrong result for 
g_date_time_new_from_iso8601(\"%s\"): for valid timestamp\n",
                                         str);
                                return FALSE;
                        }
@@ -217,7 +217,7 @@ test_parse_iso8601_timestamp (void)
                              (((gint) ((g_date_time_get_seconds (timestamp) - g_date_time_get_second 
(timestamp)) * 1000000.0))
                                                                                        != (gint) 
tt.fraction) ||
                              ((g_date_time_get_utc_offset (timestamp) / 1000000) != tt.timezone)))) {
-                               g_print ("test_parse_iso8601_timestamp: Wrong result for 
gda_parse_iso8601_timestamp (\"%s\"):\n"
+                               g_print ("test_parse_iso8601_timestamp: Wrong result for 
g_date_time_new_from_iso8601(\"%s\"):\n"
                                         "   exp: DD=%d MM=%d YYYY=%d HH=%d MM=%d SS=%d FF=%ld TZ=%ld\n"
                                         "   got: DD=%d MM=%d YYYY=%d HH=%d MM=%d SS=%d FF=%ld TZ=%ld\n",
                                         str, td.exp_day, td.exp_month, td.exp_year,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]