ICU-10822 C wrapper implementation for udat_get.../udat_setBooleanAttribute
X-SVN-Rev: 35615
This commit is contained in:
parent
93559e74a8
commit
b30a917348
@ -310,6 +310,26 @@ udat_setLenient( UDateFormat* fmt,
|
|||||||
((DateFormat*)fmt)->setLenient(isLenient);
|
((DateFormat*)fmt)->setLenient(isLenient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U_DRAFT UBool U_EXPORT2
|
||||||
|
udat_getBooleanAttribute(const UDateFormat* fmt,
|
||||||
|
UDateFormatBooleanAttribute attr,
|
||||||
|
UErrorCode* status)
|
||||||
|
{
|
||||||
|
if(U_FAILURE(*status)) return FALSE;
|
||||||
|
return ((DateFormat*)fmt)->getBooleanAttribute(attr, *status);
|
||||||
|
//return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_DRAFT void U_EXPORT2
|
||||||
|
udat_setBooleanAttribute(UDateFormat *fmt,
|
||||||
|
UDateFormatBooleanAttribute attr,
|
||||||
|
UBool newValue,
|
||||||
|
UErrorCode* status)
|
||||||
|
{
|
||||||
|
if(U_FAILURE(*status)) return;
|
||||||
|
((DateFormat*)fmt)->setBooleanAttribute(attr, newValue, *status);
|
||||||
|
}
|
||||||
|
|
||||||
U_CAPI const UCalendar* U_EXPORT2
|
U_CAPI const UCalendar* U_EXPORT2
|
||||||
udat_getCalendar(const UDateFormat* fmt)
|
udat_getCalendar(const UDateFormat* fmt)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
* Copyright (c) 1997-2014, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@ -38,6 +38,8 @@ void addDtFrDepTest(TestNode** root)
|
|||||||
addTest(root, &TestRunTogetherPattern985, "tsformat/cdtdptst/TestRunTogetherPattern985");
|
addTest(root, &TestRunTogetherPattern985, "tsformat/cdtdptst/TestRunTogetherPattern985");
|
||||||
addTest(root, &TestCzechMonths459, "tsformat/cdtdptst/TestCzechMonths459");
|
addTest(root, &TestCzechMonths459, "tsformat/cdtdptst/TestCzechMonths459");
|
||||||
addTest(root, &TestQuotePattern161, "tsformat/cdtdptst/TestQuotePattern161");
|
addTest(root, &TestQuotePattern161, "tsformat/cdtdptst/TestQuotePattern161");
|
||||||
|
addTest(root, &TestBooleanAttributes, "tsformat/cdtdptst/TestBooleanAttributes");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,4 +351,35 @@ void TestQuotePattern161()
|
|||||||
ctest_resetTimeZone();
|
ctest_resetTimeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testing udat_getBooleanAttribute and unum_setBooleanAttribute() to make sure basic C wrapper functionality is present
|
||||||
|
*/
|
||||||
|
static void TestBooleanAttributes(void)
|
||||||
|
{
|
||||||
|
UDateFormat *en;
|
||||||
|
UErrorCode status=U_ZERO_ERROR;
|
||||||
|
UBool initialState = TRUE;
|
||||||
|
UBool switchedState = FALSE;
|
||||||
|
|
||||||
|
log_verbose("\ncreating a date format with english locale\n");
|
||||||
|
en = udat_open(UDAT_FULL, UDAT_DEFAULT, "en_US", NULL, 0, NULL, 0, &status);
|
||||||
|
if(U_FAILURE(status)) {
|
||||||
|
log_data_err("error in creating the dateformat -> %s (Are you missing data?)\n",
|
||||||
|
myErrorName(status) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
initialState = udat_getBooleanAttribute(en, UDAT_PARSE_ALLOW_NUMERIC, &status);
|
||||||
|
if(initialState != TRUE) switchedState = TRUE; // if it wasn't the default of TRUE, then flip what we expect
|
||||||
|
|
||||||
|
udat_setBooleanAttribute(en, UDAT_PARSE_ALLOW_NUMERIC, switchedState, &status);
|
||||||
|
if(switchedState != udat_getBooleanAttribute(en, UDAT_PARSE_ALLOW_NUMERIC, &status)) {
|
||||||
|
log_err("unable to switch states!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
udat_close(en);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
* Copyright (c) 1997-2014, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@ -52,6 +52,11 @@ void TestQuotePattern161(void);
|
|||||||
/*Internal functions used*/
|
/*Internal functions used*/
|
||||||
void tryPat994(UDateFormat* format, const char* pat, const char* s, UDate expected);
|
void tryPat994(UDateFormat* format, const char* pat, const char* s, UDate expected);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testing udat_getBooleanAttribute and unum_setBooleanAttribute()
|
||||||
|
*/
|
||||||
|
void TestBooleanAttributes(void);
|
||||||
|
|
||||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user