[libgda] Added gda_time_valid() and gda_timestamp_valid(), thanks to Andrea Zagli
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added gda_time_valid() and gda_timestamp_valid(), thanks to Andrea Zagli
- Date: Tue, 13 Jul 2010 20:33:44 +0000 (UTC)
commit 8ccc54aa2dc0e7e9ed09790ddaf12727f6770644
Author: Vivien Malerba <malerba gnome-db org>
Date: Tue Jul 13 22:32:53 2010 +0200
Added gda_time_valid() and gda_timestamp_valid(), thanks to Andrea Zagli
doc/C/libgda-sections.txt | 2 +
libgda/gda-value.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
libgda/gda-value.h | 4 +++
libgda/libgda.symbols | 2 +
4 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/doc/C/libgda-sections.txt b/doc/C/libgda-sections.txt
index fd21f96..a6abc7b 100644
--- a/doc/C/libgda-sections.txt
+++ b/doc/C/libgda-sections.txt
@@ -770,12 +770,14 @@ gda_value_set_numeric
GdaTime
gda_time_copy
gda_time_free
+gda_time_valid
gda_value_get_time
gda_value_set_time
<SUBSECTION>
GdaTimestamp
gda_timestamp_copy
gda_timestamp_free
+gda_timestamp_valid
gda_value_get_timestamp
gda_value_set_timestamp
gda_value_new_timestamp_from_timet
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 382fb58..afa5045 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -948,6 +948,26 @@ gda_time_free (gpointer boxed)
g_free (boxed);
}
+/**
+ * gda_time_valid
+ * @time: a #GdaTime value to check if it is valid
+ *
+ * Returns: #TRUE if #GdaTime is valid; FALSE otherwise.
+ *
+ * Since: 4.2
+ */
+gboolean
+gda_time_valid (const GdaTime *time)
+{
+ g_return_val_if_fail (time, FALSE);
+
+ if (time->hour < 0 || time->hour > 24 ||
+ time->minute < 0 || time->minute > 59 ||
+ time->second < 0 || time->second > 59)
+ return FALSE;
+ else
+ return TRUE;
+}
/*
@@ -1063,7 +1083,40 @@ gda_timestamp_free (gpointer boxed)
g_free (boxed);
}
+/**
+ * gda_timestamp_valid
+ * @timestamp: a #GdaTimestamp value to check if it is valid
+ *
+ * Returns: #TRUE if #GdaTimestamp is valid; FALSE otherwise.
+ *
+ * Since: 4.2
+ */
+gboolean
+gda_timestamp_valid (const GdaTimestamp *timestamp)
+{
+ g_return_val_if_fail (timestamp, FALSE);
+
+ GDate *gdate;
+ /* check the date part */
+ gdate = g_date_new_dmy ((GDateDay) timestamp->day, (GDateMonth) timestamp->month,
+ (GDateYear) timestamp->year);
+ if (!gdate)
+ return FALSE;
+ if (! g_date_valid (gdate)) {
+ g_date_free (gdate);
+ return FALSE;
+ }
+ g_date_free (gdate);
+
+ /* check the time part */
+ if (timestamp->hour < 0 || timestamp->hour > 24 ||
+ timestamp->minute < 0 || timestamp->minute > 59 ||
+ timestamp->second < 0 || timestamp->second > 59)
+ return FALSE;
+ else
+ return TRUE;
+}
/**
* gda_value_new
diff --git a/libgda/gda-value.h b/libgda/gda-value.h
index 64b7f1d..ac1d5d5 100644
--- a/libgda/gda-value.h
+++ b/libgda/gda-value.h
@@ -184,10 +184,14 @@ void gda_numeric_free (gpointer boxed);
GType gda_time_get_type (void) G_GNUC_CONST;
gpointer gda_time_copy (gpointer boxed);
void gda_time_free (gpointer boxed);
+gboolean gda_time_valid (const GdaTime *time);
+
GType gda_timestamp_get_type (void) G_GNUC_CONST;
gpointer gda_timestamp_copy (gpointer boxed);
void gda_timestamp_free (gpointer boxed);
+gboolean gda_timestamp_valid (const GdaTimestamp *timestamp);
+
GType gda_geometricpoint_get_type (void) G_GNUC_CONST;
gpointer gda_geometricpoint_copy (gpointer boxed);
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index a3393b1..f48b266 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -786,9 +786,11 @@
gda_time_copy
gda_time_free
gda_time_get_type
+ gda_time_valid
gda_timestamp_copy
gda_timestamp_free
gda_timestamp_get_type
+ gda_timestamp_valid
gda_transaction_isolation_get_type
gda_transaction_status_add_event_sql
gda_transaction_status_add_event_sub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]