]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/reldatefmt.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / reldatefmt.cpp
index 9d26910067cc134637999633306e4b4235f67094..fa3c27e17f39002176b422fd0d72d6bfa05666ca 100644 (file)
@@ -43,7 +43,7 @@
 #include "standardplural.h"
 #include "unifiedcache.h"
 #include "util.h"
-#include "number_stringbuilder.h"
+#include "formatted_string_builder.h"
 #include "number_utypes.h"
 #include "number_modifiers.h"
 #include "formattedval_impl.h"
@@ -315,6 +315,10 @@ struct RelDateTimeFmtDataSink : public ResourceSink {
                 return UDAT_ABSOLUTE_FRIDAY;
             case SATURDAY:
                 return UDAT_ABSOLUTE_SATURDAY;
+            case HOUR:
+                return UDAT_ABSOLUTE_HOUR;
+            case MINUTE:
+                return UDAT_ABSOLUTE_MINUTE;
             default:
                 return -1;
         }
@@ -714,7 +718,7 @@ const RelativeDateTimeCacheData *LocaleCacheKey<RelativeDateTimeCacheData>::crea
         return nullptr;
     }
     result->adoptCombinedDateAndTime(
-            new SimpleFormatter(dateTimePattern, 2, 2, status));
+            new SimpleFormatter(dateTimePattern, 2, 2, TRUE, status));
     if (U_FAILURE(status)) {
         return nullptr;
     }
@@ -725,14 +729,14 @@ const RelativeDateTimeCacheData *LocaleCacheKey<RelativeDateTimeCacheData>::crea
 
 
 static constexpr number::impl::Field kRDTNumericField
-    = number::impl::NumFieldUtils::compress<UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD>();
+    = StringBuilderFieldUtils::compress<UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD>();
 
 static constexpr number::impl::Field kRDTLiteralField
-    = number::impl::NumFieldUtils::compress<UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD>();
+    = StringBuilderFieldUtils::compress<UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD>();
 
-class FormattedRelativeDateTimeData : public FormattedValueNumberStringBuilderImpl {
+class FormattedRelativeDateTimeData : public FormattedValueStringBuilderImpl {
 public:
-    FormattedRelativeDateTimeData() : FormattedValueNumberStringBuilderImpl(kRDTNumericField) {}
+    FormattedRelativeDateTimeData() : FormattedValueStringBuilderImpl(kRDTNumericField) {}
     virtual ~FormattedRelativeDateTimeData();
 };
 
@@ -1157,6 +1161,8 @@ void RelativeDateTimeFormatter::formatRelativeImpl(
         case UDAT_REL_UNIT_THURSDAY:  absunit = UDAT_ABSOLUTE_THURSDAY; break;
         case UDAT_REL_UNIT_FRIDAY:  absunit = UDAT_ABSOLUTE_FRIDAY; break;
         case UDAT_REL_UNIT_SATURDAY:  absunit = UDAT_ABSOLUTE_SATURDAY; break;
+        case UDAT_REL_UNIT_HOUR:  absunit = UDAT_ABSOLUTE_HOUR; break;
+        case UDAT_REL_UNIT_MINUTE:  absunit = UDAT_ABSOLUTE_MINUTE; break;
         default: break;
     }
     if (direction != UDAT_DIRECTION_COUNT && absunit != UDAT_ABSOLUTE_UNIT_COUNT) {
@@ -1184,8 +1190,8 @@ UnicodeString& RelativeDateTimeFormatter::adjustForContext(UnicodeString &str) c
 
     // Must guarantee that one thread at a time accesses the shared break
     // iterator.
-    static UMutex *gBrkIterMutex = STATIC_NEW(UMutex);
-    Mutex lock(gBrkIterMutex);
+    static UMutex gBrkIterMutex;
+    Mutex lock(&gBrkIterMutex);
     str.toTitle(
             fOptBreakIterator->get(),
             fLocale,