Logo Search packages:      
Sourcecode: icu version File versions  Download package

void DateIntervalInfo::setIntervalPattern ( const UnicodeString skeleton,
UCalendarDateFields  lrgDiffCalUnit,
const UnicodeString intervalPattern,
UErrorCode status 
)

Provides a way for client to build interval patterns. User could construct DateIntervalInfo by providing a list of skeletons and their patterns.

For example:

 UErrorCode status = U_ZERO_ERROR;
 DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
 dIntervalInfo->setFallbackIntervalPattern("{0} ~ {1}");
 dIntervalInfo->setIntervalPattern("yMd", UCAL_YEAR, "'from' yyyy-M-d 'to' yyyy-M-d", status); 
 dIntervalInfo->setIntervalPattern("yMMMd", UCAL_MONTH, "'from' yyyy MMM d 'to' MMM d", status);
 dIntervalInfo->setIntervalPattern("yMMMd", UCAL_DAY, "yyyy MMM d-d", status, status);
 

Restriction: Currently, users can only set interval patterns when the following calendar fields are different: ERA, YEAR, MONTH, DATE, DAY_OF_MONTH, DAY_OF_WEEK, AM_PM, HOUR, HOUR_OF_DAY, and MINUTE. Interval patterns when other calendar fields are different are not supported.

Parameters:
skeleton the skeleton on which interval pattern based
lrgDiffCalUnit the largest different calendar unit.
intervalPattern the interval pattern on the largest different calendar unit. For example, if lrgDiffCalUnit is "year", the interval pattern for en_US when year is different could be "'from' yyyy 'to' yyyy".
status output param set to success/failure code on exit ICU 4.0

Definition at line 82 of file dtitvinf.cpp.

References UCAL_AM_PM, UCAL_DATE, UCAL_DAY_OF_MONTH, UCAL_DAY_OF_WEEK, UCAL_HOUR, and UCAL_HOUR_OF_DAY.

Referenced by DateIntervalFormatTest::expectUserDII(), and DateIntervalFormatTest::stress().

                                                         {
    
    if ( lrgDiffCalUnit == UCAL_HOUR_OF_DAY ) {
        setIntervalPatternInternally(skeleton, UCAL_AM_PM, intervalPattern, status);
        setIntervalPatternInternally(skeleton, UCAL_HOUR, intervalPattern, status);
    } else if ( lrgDiffCalUnit == UCAL_DAY_OF_MONTH ||
                lrgDiffCalUnit == UCAL_DAY_OF_WEEK ) {
        setIntervalPatternInternally(skeleton, UCAL_DATE, intervalPattern, status);
    } else {
        setIntervalPatternInternally(skeleton, lrgDiffCalUnit, intervalPattern, status);
    }
}


Generated by  Doxygen 1.6.0   Back to index