Logo Search packages:      
Sourcecode: icu version File versions

void DateIntervalFormat::setIntervalPattern ( UCalendarDateFields  field,
const UnicodeString intervalPattern,
UBool  laterDateFirst 
) [private]

Break interval patterns as 2 part and save them into pattern info.

Parameters:
field calendar field
intervalPattern interval pattern
laterDateFirst whether later date appear first in interval pattern

For internal use only.

ICU 4.0

Definition at line 1012 of file dtitvfmt.cpp.

References UnicodeString::extract(), UnicodeString::length(), setPatternInfo(), splitPatternInto2Part(), and UnicodeString::startsWith().

                                                             {
    const UnicodeString* pattern = &intervalPattern;
    UBool order = laterDateFirst;
    // check for "latestFirst:" or "earliestFirst:" prefix
    int8_t prefixLength = sizeof(gLaterFirstPrefix)/sizeof(gLaterFirstPrefix[0]);
    int8_t earliestFirstLength = sizeof(gEarlierFirstPrefix)/sizeof(gEarlierFirstPrefix[0]);
    UnicodeString realPattern;
    if ( intervalPattern.startsWith(gLaterFirstPrefix, prefixLength) ) {
        order = true;
        intervalPattern.extract(prefixLength, 
                                intervalPattern.length() - prefixLength,
                                realPattern);
        pattern = &realPattern;
    } else if ( intervalPattern.startsWith(gEarlierFirstPrefix,
                                           earliestFirstLength) ) {
        order = false;
        intervalPattern.extract(earliestFirstLength,
                                intervalPattern.length() - earliestFirstLength,
                                realPattern);
        pattern = &realPattern;
    }

    int32_t splitPoint = splitPatternInto2Part(*pattern);
    
    UnicodeString firstPart;
    UnicodeString secondPart;
    pattern->extract(0, splitPoint, firstPart);
    if ( splitPoint < pattern->length() ) {
        pattern->extract(splitPoint, pattern->length()-splitPoint, secondPart);
    }
    setPatternInfo(field, &firstPart, &secondPart, order);
}


Generated by  Doxygen 1.6.0   Back to index