]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/windtfmt.cpp
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / i18n / windtfmt.cpp
index 19766b1f637e3c2422028047ddc889b2bfd4372b..0fda3419bcee60713d6a32c92505e94cbc1a3775 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ********************************************************************************
-*   Copyright (C) 2005-2006, International Business Machines
+*   Copyright (C) 2005-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 *
@@ -11,7 +11,7 @@
 
 #include "unicode/utypes.h"
 
-#ifdef U_WINDOWS
+#if U_PLATFORM_HAS_WIN32_API
 
 #if !UCONFIG_NO_FORMATTING
 
@@ -31,7 +31,7 @@
 #include "cmemory.h"
 #include "uresimp.h"
 #include "windtfmt.h"
-#include "wintz.h"
+#include "wintzimpl.h"
 
 #   define WIN32_LEAN_AND_MEAN
 #   define VC_EXTRALEAN
@@ -52,7 +52,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Win32DateFormat)
 
 #define STACK_BUFFER_SIZE 64
 
-UnicodeString *getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status)
+UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const
 {
     UnicodeString *result = NULL;
     const char *type = cal->getType();
@@ -69,12 +69,18 @@ UnicodeString *getTimeDateFormat(const Calendar *cal, const Locale *locale, UErr
     }
 
     if (U_FAILURE(status)) {
-        UChar defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
+        static const UChar defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
         return new UnicodeString(defaultPattern, ARRAY_SIZE(defaultPattern));
     }
 
     int32_t resStrLen = 0;
-    const UChar *resStr = ures_getStringByIndex(patBundle, (int32_t)DateFormat::kDateTime, &resStrLen, &status);
+    int32_t glueIndex = DateFormat::kDateTime;
+    int32_t patSize = ures_getSize(patBundle);
+    if (patSize >= (DateFormat::kDateTimeOffset + DateFormat::kShort + 1)) {
+        // Get proper date time format
+        glueIndex = (int32_t)(DateFormat::kDateTimeOffset + (fDateStyle - DateFormat::kDateOffset));
+    }
+    const UChar *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
 
     result = new UnicodeString(TRUE, resStr, resStrLen);
 
@@ -311,5 +317,5 @@ U_NAMESPACE_END
 
 #endif /* #if !UCONFIG_NO_FORMATTING */
 
-#endif // #ifdef U_WINDOWS
+#endif // U_PLATFORM_HAS_WIN32_API