diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c index 73250f6a85..03ad43ec3c 100644 --- a/libgimp/gimpimagemetadata-save.c +++ b/libgimp/gimpimagemetadata-save.c @@ -21,7 +21,18 @@ #include "config.h" #include +#ifdef HAVE_SYS_TIME_H #include +#endif +#if defined(_WIN32) && !defined(HAVE_SYS_TIME_H) +#include +#include +#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) +#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 +#else +#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +#endif +#endif #include @@ -619,6 +630,50 @@ gimp_image_metadata_set_xmp_structs (GList *xmp_list, return exclude; } +#if defined(_WIN32) && ! defined(HAVE_SYS_TIME_H) +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int +gettimeofday (struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + unsigned __int64 tmpres = 0; + static int tzflag = 0; + + if (NULL != tv) + { + GetSystemTimeAsFileTime (&ft); + + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + tmpres /= 10; /*convert into microseconds*/ + /*converting file time to unix epoch*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (long) (tmpres / 1000000UL); + tv->tv_usec = (long) (tmpres % 1000000UL); + } + + if (NULL != tz) + { + if (! tzflag) + { + _tzset (); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} +#endif + /** * gimp_image_metadata_save_filter: * @image: The actually saved image diff --git a/libgimp/gimpimagemetadata.c b/libgimp/gimpimagemetadata.c index 6e98c9beeb..91fc4e7e6f 100644 --- a/libgimp/gimpimagemetadata.c +++ b/libgimp/gimpimagemetadata.c @@ -21,7 +21,9 @@ #include "config.h" #include +#ifdef HAVE_SYS_TIME_H #include +#endif #include