Add support for passing a Timespec as a boxed GValue

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18769 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff
2010-03-01 18:04:33 +00:00
parent f09fa9ae58
commit 7b95d03929
2 changed files with 43 additions and 0 deletions

View File

@@ -1520,3 +1520,38 @@ gnc_dow_abbrev(gchar *buf, int buf_len, int dow)
i = qof_strftime(buf, buf_len, "%a", &my_tm);
buf[i] = 0;
}
/* *******************************************************************
* GValue handling
********************************************************************/
static gpointer
timespec_boxed_copy_func( gpointer in_timespec )
{
Timespec* newvalue;
newvalue = g_malloc( sizeof( Timespec ) );
memcpy( newvalue, in_timespec, sizeof( Timespec ) );
return newvalue;
}
static void
timespec_boxed_free_func( gpointer in_timespec )
{
g_free( in_timespec );
}
GType
timespec_get_type( void )
{
static GType type = 0;
if ( type == 0 )
{
type = g_boxed_type_register_static( "timespec",
timespec_boxed_copy_func,
timespec_boxed_free_func );
}
return type;
}

View File

@@ -67,8 +67,16 @@
#ifndef GNC_DATE_H
#define GNC_DATE_H
#include <glib-object.h>
#include <time.h>
/** @name GValue
@{
*/
GType timespec_get_type( void );
#define GNC_TYPE_TIMESPEC (timespec_get_type ())
/** @} */
/** The default date format for use with strftime. */
extern const char *gnc_default_strftime_date_format;