]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/windtfmt.cpp
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / i18n / windtfmt.cpp
index 19766b1f637e3c2422028047ddc889b2bfd4372b..8fedabd675319ddec1e8a87c92a4c68fc1810ecb 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ********************************************************************************
-*   Copyright (C) 2005-2006, International Business Machines
+*   Copyright (C) 2005-2009, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 *
@@ -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);