Hi all,

the patch changed according to zyx' suggestion is attached,
please review it, and if accepted please apply (separately)
to the public repository, otherwise please let me know why not.

@zyx: Please also review the revised patch for PdfPagesTree (in
its thread).



Best regards, mabri



----- Original Message -----
From: zyx <z...@litepdf.cz>
To: podofo-users@lists.sourceforge.net
CC: 
Sent: 7:36 Donnerstag, 1.Oktober 2015
Subject: Re: [Podofo-users] Getting rid of non-standard Win32 specifics for 
timezone (AFAIK bug-compatible)

On Wed, 2015-09-30 at 23:59 +0000, Matthew Brincke wrote:
> -    snprintf( szZone, ZONE_STRING_SIZE, "%+03d", -_timezone/3600 );
> ...
> +    snprintf( szZone, ZONE_STRING_SIZE, "%+03ld", time_off/3600 );

    Hi,
just briefly looking on the patch, the format specifiers are always a
pita. The %ld is not correct for 32bit compilation, also because the
time_t size can differ between architectures. As the actual value is
expected to not be too large, I'd prefer to use %d (without 'l') and
cast the argument to int. Note of the format specifiers in
src/base/PdfCompilerCompat.h too.
    Bye,
    zyx

P.S.: I omitted  the "+03" in the format specifier for readiness

-- 
http://www.litePDF.cz                                 i...@litepdf.cz




------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users
Index: src/base/PdfDate.cpp
===================================================================
--- src/base/PdfDate.cpp	(revision 1680)
+++ src/base/PdfDate.cpp	(working copy)
@@ -154,10 +154,15 @@
 
 #ifdef _WIN32
     // On win32, strftime with %z returns a verbose time zone name
-    // like "W. Australia Standard time". We use tzset and timezone
+    // like "W. Australia Standard time". We use time/gmtime/mktime
     // instead.
-    _tzset();
-    snprintf( szZone, ZONE_STRING_SIZE, "%+03d", -_timezone/3600 );
+    time_t cur_time = time( NULL );
+    struct tm* cur_gmt = gmtime( &cur_time );
+    // assumes _timezone cannot include DST (mabri: documentation unclear IMHO)
+
+    time_t time_off = cur_time - mktime( cur_gmt ); // interpreted as local
+    snprintf( szZone, ZONE_STRING_SIZE, "%+03d",
+            static_cast<int>( time_off/3600 ) );
 #else
     if( strftime( szZone, ZONE_STRING_SIZE, "%z", stm ) == 0 )
     {
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to