switch to GDateTime

This commit is contained in:
John Cupitt 2019-11-11 15:14:04 +00:00
parent 144a9c48f9
commit 3ba0b285d4
3 changed files with 41 additions and 3 deletions

View File

@ -485,6 +485,16 @@ PKG_CHECK_MODULES(MONOTONIC, glib-2.0 >= 2.28,
]
)
# from 2.62 we have datetime
PKG_CHECK_MODULES(DATE_TIME_FORMAT_ISO8601, glib-2.0 >= 2.62,
[AC_DEFINE(HAVE_DATE_TIME_FORMAT_ISO8601,1,
[define if your glib has g_date_time_format_iso8601().]
)
],
[:
]
)
# the old threading system
PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
PACKAGES_USED="$PACKAGES_USED gthread-2.0"

View File

@ -1132,14 +1132,28 @@ char *
build_scan_properties( VipsImage *image )
{
VipsDbuf dbuf;
GTimeVal now;
char *date;
int i;
vips_dbuf_init( &dbuf );
#ifdef HAVE_DATE_TIME_FORMAT_ISO8601
{
GDateTime *now;
now = g_date_time_new_now_local();
date = g_date_time_format_iso8601( now );
g_date_time_unref( now );
}
#else /*!HAVE_DATE_TIME_FORMAT_ISO8601*/
{
GTimeVal now;
g_get_current_time( &now );
date = g_time_val_to_iso8601( &now );
}
#endif /*HAVE_DATE_TIME_FORMAT_ISO8601*/
vips_dbuf_writef( &dbuf, "<?xml version=\"1.0\"?>\n" );
vips_dbuf_writef( &dbuf, "<image xmlns=\"http://www.pathozoom.com/szi\""
" date=\"%s\" version=\"1.0\">\n", date );

View File

@ -955,13 +955,27 @@ char *
vips__xml_properties( VipsImage *image )
{
VipsDbuf dbuf;
GTimeVal now;
char *date;
vips_dbuf_init( &dbuf );
#ifdef HAVE_DATE_TIME_FORMAT_ISO8601
{
GDateTime *now;
now = g_date_time_new_now_local();
date = g_date_time_format_iso8601( now );
g_date_time_unref( now );
}
#else /*!HAVE_DATE_TIME_FORMAT_ISO8601*/
{
GTimeVal now;
g_get_current_time( &now );
date = g_time_val_to_iso8601( &now );
date = g_time_val_to_iso8601( &now );
}
#endif /*HAVE_DATE_TIME_FORMAT_ISO8601*/
vips_dbuf_writef( &dbuf, "<?xml version=\"1.0\"?>\n" );
vips_dbuf_writef( &dbuf, "<image xmlns=\"%s/dzsave\" "
"date=\"%s\" version=\"%d.%d.%d\">\n",