Skip to content

Commit

Permalink
Add support for passing a Timespec as a boxed GValue
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18769 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
Phil Longstaff committed Mar 1, 2010
1 parent f09fa9a commit 7b95d03
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/libqof/qof/gnc-date.c
Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions src/libqof/qof/gnc-date.h
Expand Up @@ -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;

Expand Down

0 comments on commit 7b95d03

Please sign in to comment.