]> granicus.if.org Git - icu/commitdiff
ICU-9051 timezone offset fix on iOS
authorJungshik Shin <jshin@chromium.org>
Mon, 9 Sep 2013 17:58:59 +0000 (17:58 +0000)
committerJungshik Shin <jshin@chromium.org>
Mon, 9 Sep 2013 17:58:59 +0000 (17:58 +0000)
X-SVN-Rev: 34248

icu4c/source/common/putil.cpp
icu4c/source/common/putilimp.h

index a6c941b56d3cad035b07d6014ae5a971951354ea..f02cfb932b41fb68b7b151924fc6c93521df8de9 100644 (file)
@@ -639,27 +639,30 @@ uprv_timezone()
 #else
     time_t t, t1, t2;
     struct tm tmrec;
-    UBool dst_checked;
     int32_t tdiff = 0;
 
     time(&t);
     uprv_memcpy( &tmrec, localtime(&t), sizeof(tmrec) );
-    dst_checked = (tmrec.tm_isdst != 0); /* daylight savings time is checked*/
+#if U_PLATFORM != U_PF_IPHONE
+    UBool dst_checked = (tmrec.tm_isdst != 0); /* daylight savings time is checked*/
+#endif
     t1 = mktime(&tmrec);                 /* local time in seconds*/
     uprv_memcpy( &tmrec, gmtime(&t), sizeof(tmrec) );
     t2 = mktime(&tmrec);                 /* GMT (or UTC) in seconds*/
     tdiff = t2 - t1;
+
+#if U_PLATFORM != U_PF_IPHONE
     /* imitate NT behaviour, which returns same timezone offset to GMT for
        winter and summer.
        This does not work on all platforms. For instance, on glibc on Linux
        and on Mac OS 10.5, tdiff calculated above remains the same
-       regardless of whether DST is in effect or not. However, U_TIMEZONE
-       is defined on those platforms and this code is not reached so that
-       we can leave this alone. If there's a platform behaving
-       like glibc that uses this code, we need to add platform-dependent
-       preprocessor here. */
+       regardless of whether DST is in effect or not. iOS is another
+       platform where this does not work. Linux + glibc and Mac OS 10.5
+       have U_TIMEZONE defined so that this code is not reached.
+    */
     if (dst_checked)
         tdiff += 3600;
+#endif
     return tdiff;
 #endif
 }
@@ -672,7 +675,7 @@ uprv_timezone()
 extern U_IMPORT char *U_TZNAME[];
 #endif
 
-#if !UCONFIG_NO_FILE_IO && (U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS)
+#if !UCONFIG_NO_FILE_IO && ((U_PLATFORM_IS_DARWIN_BASED && (U_PLATFORM != U_PF_IPHONE)) || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS)
 /* These platforms are likely to use Olson timezone IDs. */
 #define CHECK_LOCALTIME_LINK 1
 #if U_PLATFORM_IS_DARWIN_BASED
index 986d6e0a9a9daca9c8bf3632d3882fef00203c09..afbd62297256f743b145566aaa771275a7d8ae0f 100644 (file)
@@ -126,6 +126,8 @@ typedef size_t uintptr_t;
    /* not defined */
 #elif U_PLATFORM == U_PF_OS400
    /* not defined */
+#elif U_PLATFORM == U_PF_IPHONE
+   /* not defined */
 #else
 #   define U_TIMEZONE timezone
 #endif