diff --git a/configure.ac b/configure.ac index 45ca5662..aaeacfde 100644 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index a4fe1aff..4ca05e20 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -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, "\n" ); vips_dbuf_writef( &dbuf, "\n", date ); diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index 5b43f101..3379755a 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -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, "\n" ); vips_dbuf_writef( &dbuf, "\n",