Feature #556

timegm() function should work with Windows 64bit time_t

Added by Andreas Huggel almost 9 years ago. Updated almost 8 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:exif
Target version:0.18.2

Description

In timegm.h, it defines _USE_32BIT_TIME_T because the comments say that the 64 bit time_t does not work:

/* Visual Studio C++ 2005 (8.0) uses 64 bit time_t, which doesn't work */

#if defined _MSC_VER && _MSC_VER >= 1400

  1. define _USE_32BIT_TIME_T

#endif

However, when performing a 64 bit build in Visual Studio 2008, crtdefs.h says that _USE_32BIT_TIME_T is not valid with WIN64:

#ifdef _USE_32BIT_TIME_T

#ifdef _WIN64

#error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64

#undef _USE_32BIT_TIME_T

#endif

#endif

Associated revisions

Revision 1800
Added by Robin Mills about 8 years ago

#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)

History

#1 Updated by Andreas Huggel almost 9 years ago

From Wade Peeler, AccessData:

MSVC has a similar function, but named differently: _mkgmtime(). It will adjust to the correct call depending on the build settings (_mkgmtime32() or _mkgmtime64()):

Converts a UTC time represented by a tm struct to a UTC time represented by a time_t type.

time_t _mkgmtime(
struct tm* timeptr
);

__time32_t _mkgmtime32(
struct tm* timeptr
);

__time64_t _mkgmtime64(
struct tm* timeptr
);

#2 Updated by Andreas Huggel over 8 years ago

  • Target version set to 1.0

#3 Updated by Andreas Huggel almost 8 years ago

  • Target version changed from 1.0 to 0.18.2
  • % Done changed from 0 to 100

#4 Updated by Andreas Huggel almost 8 years ago

  • Status changed from New to Resolved

#5 Updated by Andreas Huggel almost 8 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux