Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: source/i18n/datefmt.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/currunit.cpp ('k') | source/i18n/dcfmtimp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/datefmt.cpp
diff --git a/source/i18n/datefmt.cpp b/source/i18n/datefmt.cpp
index 1caeac907b9c83b6894ce3eb13d5faaac11c3888..e205bf755f3ea31cea95fd22496c1b9fd868e4be 100644
--- a/source/i18n/datefmt.cpp
+++ b/source/i18n/datefmt.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1997-2013, International Business Machines Corporation and *
+ * Copyright (C) 1997-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@@ -25,6 +25,7 @@
#include "unicode/datefmt.h"
#include "unicode/smpdtfmt.h"
#include "unicode/dtptngen.h"
+#include "unicode/udisplaycontext.h"
#include "reldtfmt.h"
#include "cstring.h"
@@ -42,7 +43,8 @@ U_NAMESPACE_BEGIN
DateFormat::DateFormat()
: fCalendar(0),
- fNumberFormat(0)
+ fNumberFormat(0),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
}
@@ -51,7 +53,8 @@ DateFormat::DateFormat()
DateFormat::DateFormat(const DateFormat& other)
: Format(other),
fCalendar(0),
- fNumberFormat(0)
+ fNumberFormat(0),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
*this = other;
}
@@ -75,6 +78,7 @@ DateFormat& DateFormat::operator=(const DateFormat& other)
fNumberFormat = NULL;
}
fBoolFlags = other.fBoolFlags;
+ fCapitalizationContext = other.fCapitalizationContext;
}
return *this;
}
@@ -102,7 +106,8 @@ DateFormat::operator==(const Format& other) const
return (this == fmt) ||
(Format::operator==(other) &&
fCalendar&&(fCalendar->isEquivalentTo(*fmt->fCalendar)) &&
- (fNumberFormat && *fNumberFormat == *fmt->fNumberFormat));
+ (fNumberFormat && *fNumberFormat == *fmt->fNumberFormat) &&
+ (fCapitalizationContext == fmt->fCapitalizationContext) );
}
//----------------------------------------------------------------------
@@ -498,6 +503,9 @@ DateFormat::setLenient(UBool lenient)
if (fCalendar != NULL) {
fCalendar->setLenient(lenient);
}
+ UErrorCode status = U_ZERO_ERROR;
+ setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, lenient, status);
+ setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, lenient, status);
}
//----------------------------------------------------------------------
@@ -505,6 +513,29 @@ DateFormat::setLenient(UBool lenient)
UBool
DateFormat::isLenient() const
{
+ UBool lenient = TRUE;
+ if (fCalendar != NULL) {
+ lenient = fCalendar->isLenient();
+ }
+ UErrorCode status = U_ZERO_ERROR;
+ return lenient
+ && getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status)
+ && getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status);
+}
+
+void
+DateFormat::setCalendarLenient(UBool lenient)
+{
+ if (fCalendar != NULL) {
+ fCalendar->setLenient(lenient);
+ }
+}
+
+//----------------------------------------------------------------------
+
+UBool
+DateFormat::isCalendarLenient() const
+{
if (fCalendar != NULL) {
return fCalendar->isLenient();
}
@@ -512,8 +543,40 @@ DateFormat::isLenient() const
return FALSE;
}
+
//----------------------------------------------------------------------
+
+void DateFormat::setContext(UDisplayContext value, UErrorCode& status)
+{
+ if (U_FAILURE(status))
+ return;
+ if ( (UDisplayContextType)((uint32_t)value >> 8) == UDISPCTX_TYPE_CAPITALIZATION ) {
+ fCapitalizationContext = value;
+ } else {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+}
+
+
+//----------------------------------------------------------------------
+
+
+UDisplayContext DateFormat::getContext(UDisplayContextType type, UErrorCode& status) const
+{
+ if (U_FAILURE(status))
+ return (UDisplayContext)0;
+ if (type != UDISPCTX_TYPE_CAPITALIZATION) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return (UDisplayContext)0;
+ }
+ return fCapitalizationContext;
+}
+
+
+//----------------------------------------------------------------------
+
+
DateFormat&
DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr,
UBool newValue,
« no previous file with comments | « source/i18n/currunit.cpp ('k') | source/i18n/dcfmtimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698