[gnome-db] check gdatime and gdatimestamp validity
- From: Andrea Zagli <azagli libero it>
- To: gnome-db list <gnome-db-list gnome org>
- Subject: [gnome-db] check gdatime and gdatimestamp validity
- Date: Sat, 10 Jul 2010 13:01:10 +0200
i wrote these two functions to validate gdatime and gdatimestamp
/**
* gda_time_valid
* @time: a #GdaTime value to check if it is valid
*
* Returns: #TRUE if #GdaTime is valid; FALSE otherwise.
*/
gboolean
gda_time_valid (const GdaTime *time)
{
g_return_val_if_fail (time != NULL, FALSE);
if (time->hour < 0 || time->hour > 24
|| time->minute < 0 || time->minute > 59
|| time->second < 0 || time->second > 59)
return FALSE;
/* TODO i don't undestand how timestamp->timezone work */
/* TODO i don't know how timestamp->fraction work */
return TRUE;
}
/**
* gda_timestamp_valid
* @timestamp: a #GdaTimestamp value to check if it is valid
*
* Returns: #TRUE if #GdaTimestamp is valid; FALSE otherwise.
*/
gboolean
gda_timestamp_valid (const GdaTimestamp *timestamp)
{
g_return_val_if_fail (timestamp != NULL, FALSE);
GDate *gdate;
/* check the date part */
gdate = g_date_new_dmy ((GDateDay)timestamp->day,
(GDateMonth)timestamp->month, (GDateYear)timestamp->year);
if (gdate == NULL)
return FALSE;
/* 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;
/* TODO i don't undestand how timestamp->timezone work */
/* TODO i don't know how timestamp->fraction work */
return TRUE;
}
if you think that it can be useful inside libgda, fell free to use
them (i think that libgda functions operating on gdatime and gdatime
(ex. gda_value_get_timestamp) must before validate the value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]