]> granicus.if.org Git - icu/commitdiff
ICU-9857 Adjust for CLDR calendar <fields> move to top of <dates> element (C)
authorPeter Edberg <pedberg@unicode.org>
Sat, 26 Jan 2013 00:15:50 +0000 (00:15 +0000)
committerPeter Edberg <pedberg@unicode.org>
Sat, 26 Jan 2013 00:15:50 +0000 (00:15 +0000)
X-SVN-Rev: 33076

icu4c/source/i18n/dtptngen.cpp
icu4c/source/i18n/reldtfmt.cpp

index 3cbfb19535646651f8106ec9f386b245b875500c..8d9646def112c22a3aaf5378b31c1d1d902c7ddd 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 2007-2012, International Business Machines Corporation and
+* Copyright (C) 2007-2013, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 *
@@ -589,7 +589,7 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
 
     key=NULL;
     err = U_ZERO_ERROR;
-    fBundle = ures_getByKeyWithFallback(calTypeBundle, DT_DateTimeFieldsTag, NULL, &err);
+    fBundle = ures_getByKeyWithFallback(rb, DT_DateTimeFieldsTag, NULL, &err);
     for (i=0; i<MAX_RESOURCE_FIELD; ++i) {
         err = U_ZERO_ERROR;
         patBundle = ures_getByKeyWithFallback(fBundle, Resource_Fields[i], NULL, &err);
index 3e65939a08072c4b8931ccc908557b382f1dfa87..723b0c9a0e888dd9ead084667921f26f7944d306 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 2007-2012, International Business Machines Corporation and
+* Copyright (C) 2007-2013, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 */
@@ -18,6 +18,7 @@
 
 #include "gregoimp.h" // for CalendarData
 #include "cmemory.h"
+#include "uresimp.h"
 
 U_NAMESPACE_BEGIN
 
@@ -423,17 +424,22 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
         }
     }
 
-    UResourceBundle *strings = calData.getByKey3("fields", "day", "relative", status);
+    UResourceBundle *rb = ures_open(NULL, fLocale.getBaseName(), &status);
+    UResourceBundle *sb = ures_getByKeyWithFallback(rb, "fields", NULL, &status);
+    rb = ures_getByKeyWithFallback(sb, "day", rb, &status);
+    sb = ures_getByKeyWithFallback(rb, "relative", sb, &status);
+    ures_close(rb);
     // set up min/max 
     fDayMin=-1;
     fDayMax=1;
 
     if(U_FAILURE(status)) {
         fDatesLen=0;
+        ures_close(sb);
         return;
     }
 
-    fDatesLen = ures_getSize(strings);
+    fDatesLen = ures_getSize(sb);
     fDates = (URelativeString*) uprv_malloc(sizeof(fDates[0])*fDatesLen);
 
     // Load in each item into the array...
@@ -441,8 +447,8 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
 
     UResourceBundle *subString = NULL;
     
-    while(ures_hasNext(strings) && U_SUCCESS(status)) {  // iterate over items
-        subString = ures_getNextResource(strings, subString, &status);
+    while(ures_hasNext(sb) && U_SUCCESS(status)) {  // iterate over items
+        subString = ures_getNextResource(sb, subString, &status);
         
         if(U_FAILURE(status) || (subString==NULL)) break;
         
@@ -474,6 +480,7 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
         n++;
     }
     ures_close(subString);
+    ures_close(sb);
     
     // the fDates[] array could be sorted here, for direct access.
 }