[libgda] GdaSql: better handle date formatting
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaSql: better handle date formatting
- Date: Thu, 26 Sep 2013 19:34:06 +0000 (UTC)
commit 8dc5c8bd85b5baf0a46faae7cdbaf5ba0ad596ac
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Sep 26 21:27:19 2013 +0200
GdaSql: better handle date formatting
tools/cmdtool/tool-output.c | 20 +++++++++++---------
tools/gda-sql.c | 20 +++++++++++++++++---
2 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/tools/cmdtool/tool-output.c b/tools/cmdtool/tool-output.c
index d856595..8feca5c 100644
--- a/tools/cmdtool/tool-output.c
+++ b/tools/cmdtool/tool-output.c
@@ -68,18 +68,20 @@ data_model_to_string (GdaDataModel *model, ToolOutputFormat format, FILE *stream
if (format & TOOL_OUTPUT_FORMAT_DEFAULT) {
gchar *tmp;
- GdaSet *options;
+ GdaSet *local_options;
gint width;
input_get_size (&width, NULL);
- options = gda_set_new_inline (6, "NAME", G_TYPE_BOOLEAN, TRUE,
- "NULL_AS_EMPTY", G_TYPE_BOOLEAN, TRUE,
- "MAX_WIDTH", G_TYPE_INT, width,
- "COLUMN_SEPARATORS", G_TYPE_BOOLEAN, TRUE,
- "SEPARATOR_LINE", G_TYPE_BOOLEAN, TRUE,
- "NAMES_ON_FIRST_LINE", G_TYPE_BOOLEAN, TRUE);
+ local_options = gda_set_new_inline (6, "NAME", G_TYPE_BOOLEAN, TRUE,
+ "NULL_AS_EMPTY", G_TYPE_BOOLEAN, TRUE,
+ "MAX_WIDTH", G_TYPE_INT, width,
+ "COLUMN_SEPARATORS", G_TYPE_BOOLEAN, TRUE,
+ "SEPARATOR_LINE", G_TYPE_BOOLEAN, TRUE,
+ "NAMES_ON_FIRST_LINE", G_TYPE_BOOLEAN, TRUE);
+ if (options)
+ gda_set_merge_with_set (local_options, options);
tmp = gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_TEXT_TABLE, NULL, 0, NULL, 0,
- options);
- g_object_unref (options);
+ local_options);
+ g_object_unref (local_options);
if (GDA_IS_DATA_SELECT (model)) {
gchar *tmp2, *tmp3;
gdouble etime;
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index 16369c5..15d0c58 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 - 2012 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2007 - 2013 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2008 Murray Cumming <murrayc murrayc com>
* Copyright (C) 2008 Nathan <nbinont yahoo ca>
* Copyright (C) 2009 Bas Driessen <bas driessen xobas com>
@@ -1401,7 +1401,18 @@ open_connection (SqlConsole *console, const gchar *cnc_name, const gchar *cnc_st
main_data->settings = g_slist_append (main_data->settings, cs);
console->current = cs;
-
+
+ /* show date format */
+ GDateDMY order[3];
+ gchar sep;
+ if (gda_connection_get_date_format (cs->cnc, &order[0], &order[1], &order[2], &sep, NULL)) {
+ g_print (_("Date format for this connection will be: %s%c%s%c%s, where YYYY is the
year, MM the month and DD the day\n"),
+ (order [0] == G_DATE_DAY) ? "DD" : ((order [0] == G_DATE_MONTH) ? "MM" :
"YYYY"), sep,
+ (order [1] == G_DATE_DAY) ? "DD" : ((order [1] == G_DATE_MONTH) ? "MM" :
"YYYY"), sep,
+ (order [2] == G_DATE_DAY) ? "DD" : ((order [2] == G_DATE_MONTH) ? "MM" :
"YYYY"));
+ }
+
+ /* dictionay related work */
GdaMetaStore *store;
gboolean update_store = FALSE;
@@ -1720,7 +1731,10 @@ data_model_to_string (SqlConsole *console, GdaDataModel *model)
of = console->output_format;
if (of & TOOL_OUTPUT_FORMAT_DEFAULT) {
gchar *tmp;
- tmp = gda_data_model_dump_as_string (model);
+ GdaSet *options;
+ options = gda_set_new_inline (1, "MAX_WIDTH", G_TYPE_INT, -1);
+ tmp = gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_TEXT_TABLE, NULL, 0, NULL, 0,
options);
+ g_object_unref (options);
if (GDA_IS_DATA_SELECT (model)) {
gchar *tmp2, *tmp3;
gdouble etime;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]