#556 timegm() function should work with Windows 64bit time_t

Fix submitted.
1) Removed _USE_32BIT_TIME_T from code base.
2) Added a macro to replace timegm() with _mkgmtime() on VC8+ (supports 32 and 64 bit time_t)

Simple test performed on VC 7.1/8 and 9 (VS 2003/05/08)
C:\gnu\exiv2\msvc\bin\Release>exiv2 -a 1:00:00 ad \R.tiff && exiv2 -pt \R.tiff | grep DateTimeOriginal
Exif.Photo.DateTimeOriginal                  Ascii      20  2009:04:26 10:38:18
C:\gnu\exiv2\msvc\bin\Release>exiv2 -a 1:00:00 ad \R.tiff && exiv2 -pt \R.tiff | grep -i time
Exif.Image.DateTimeOriginal                  Ascii      20  2009:04:26 11:38:18
C:\gnu\exiv2\msvc\bin\Release>

3) Cosmetic fix to basicio.cpp
Fixed nasty little <tab> I missed when I committed basicio.cpp on Sunday (apologies)
This commit is contained in:
Robin Mills 2009-05-19 03:48:42 +00:00
parent 61ca4b9b20
commit ab8010ffd7
3 changed files with 15 additions and 6 deletions

View File

@ -383,7 +383,7 @@ namespace Exiv2 {
int FileIo::close()
{
munmap();
munmap();
if (fp_ != 0) {
std::fclose(fp_);
fp_= 0;

View File

@ -1412,6 +1412,9 @@ const long offset;
/* ahu: deleted definition of timelocal */
/* rmills - timegm is replaced with _mkgmtime on VC 2005 and up */
/* - see timegm.h */
#if !defined(_MSC_VER) || (_MSC_VER < 1400)
time_t
timegm(tmp)
struct tm * const tmp;
@ -1419,6 +1422,11 @@ struct tm * const tmp;
tmp->tm_isdst = 0;
return time1(tmp, gmtsub, 0L);
}
#endif
/* ahu: deleted definition of timeoff */

View File

@ -6,11 +6,6 @@
#ifndef TIMEGM_H_
#define TIMEGM_H_
/* Visual Studio C++ 2005 (8.0) uses 64 bit time_t, which doesn't work */
#if defined _MSC_VER && _MSC_VER >= 1400
# define _USE_32BIT_TIME_T
#endif
#include <time.h>
/*
@ -84,7 +79,13 @@ extern "C" {
#endif
// The UTC version of mktime
/* rmills - timegm is replaced with _mkgmtime on VC 2005 and up */
/* - see localtime.c */
#if !defined(_MSC_VER) || (_MSC_VER < 1400)
time_t timegm(struct tm * const tmp);
#else
#define timegm _mkgmtime
#endif
#ifdef __cplusplus
}