]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/reldtfmt.cpp
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / reldtfmt.cpp
index 81fb77749a594745c48d5daa863e6bad5705f899..5856d3fe37cd55322b23390dc5f09ad9ab008c27 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 2007-2014, International Business Machines Corporation and
+* Copyright (C) 2007-2016, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 */
@@ -13,8 +13,8 @@
 
 #include "reldtfmt.h"
 #include "unicode/datefmt.h"
+#include "unicode/simpleformatter.h"
 #include "unicode/smpdtfmt.h"
-#include "unicode/msgfmt.h"
 #include "unicode/udisplaycontext.h"
 #include "unicode/uchar.h"
 #include "unicode/brkiter.h"
@@ -56,7 +56,7 @@ RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) :
         fDateTimeFormatter = (SimpleDateFormat*)other.fDateTimeFormatter->clone();
     }
     if(other.fCombinedFormat != NULL) {
-        fCombinedFormat = (MessageFormat*)other.fCombinedFormat->clone();
+        fCombinedFormat = new SimpleFormatter(*other.fCombinedFormat);
     }
     if (fDatesLen > 0) {
         fDates = (URelativeString*) uprv_malloc(sizeof(fDates[0])*fDatesLen);
@@ -211,12 +211,11 @@ UnicodeString& RelativeDateFormat::format(  Calendar& cal,
             datePattern.setTo(fDatePattern);
         }
         UnicodeString combinedPattern;
-        Formattable timeDatePatterns[] = { fTimePattern, datePattern };
-        fCombinedFormat->format(timeDatePatterns, 2, combinedPattern, pos, status); // pos is ignored by this
+        fCombinedFormat->format(fTimePattern, datePattern, combinedPattern, status);
         fDateTimeFormatter->applyPattern(combinedPattern);
         fDateTimeFormatter->format(cal,appendTo,pos);
     }
-    
+
     return appendTo;
 }
 
@@ -308,8 +307,7 @@ void RelativeDateFormat::parse( const UnicodeString& text,
             }
         }
         UnicodeString combinedPattern;
-        Formattable timeDatePatterns[] = { fTimePattern, fDatePattern };
-        fCombinedFormat->format(timeDatePatterns, 2, combinedPattern, fPos, status); // pos is ignored by this
+        fCombinedFormat->format(fTimePattern, fDatePattern, combinedPattern, status);
         fDateTimeFormatter->applyPattern(combinedPattern);
         fDateTimeFormatter->parse(modifiedText,cal,pos);
 
@@ -381,9 +379,7 @@ RelativeDateFormat::toPattern(UnicodeString& result, UErrorCode& status) const
         } else if (fTimePattern.isEmpty() || fCombinedFormat == NULL) {
             result.setTo(fDatePattern);
         } else {
-            Formattable timeDatePatterns[] = { fTimePattern, fDatePattern };
-            FieldPosition pos;
-            fCombinedFormat->format(timeDatePatterns, 2, result, pos, status);
+            fCombinedFormat->format(fTimePattern, fDatePattern, result, status);
         }
     }
     return result;
@@ -514,7 +510,7 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
             if (U_SUCCESS(tempStatus) && resStrLen >= patItem1Len && u_strncmp(resStr,patItem1,patItem1Len)==0) {
                 fCombinedHasDateAtStart = TRUE;
             }
-            fCombinedFormat = new MessageFormat(UnicodeString(TRUE, resStr, resStrLen), fLocale, tempStatus);
+            fCombinedFormat = new SimpleFormatter(UnicodeString(TRUE, resStr, resStrLen), 2, 2, tempStatus);
         }
     }