Logo Search packages:      
Sourcecode: icu version File versions

UBool SimpleDateFormat::isFieldUnitIgnored ( const UnicodeString pattern,
UCalendarDateFields  field 
) [static]

This is for ICU internal use only. Please do not use. Check whether the 'field' is smaller than all the fields covered in pattern, return TRUE if it is. The sequence of calendar field, from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...

Parameters:
patternthe pattern to check against
fieldthe calendar field need to check against
Returns:
TRUE if the 'field' is smaller than all the fields covered in pattern. FALSE otherwise. ICU 4.0

Definition at line 3342 of file smpdtfmt.cpp.

References FALSE, fgCalendarFieldToLevel, UnicodeString::length(), and TRUE.

                                                                {
    int32_t fieldLevel = fgCalendarFieldToLevel[field];
    int32_t level;
    UChar ch;
    UBool inQuote = FALSE;
    UChar prevCh = 0;
    int32_t count = 0;

    for (int32_t i = 0; i < pattern.length(); ++i) {
        ch = pattern[i];
        if (ch != prevCh && count > 0) {
            level = fgPatternCharToLevel[prevCh - PATTERN_CHAR_BASE];
            // the larger the level, the smaller the field unit.
            if ( fieldLevel <= level ) {
                return FALSE;
            }
            count = 0;
        }
        if (ch == QUOTE) {
            if ((i+1) < pattern.length() && pattern[i+1] == QUOTE) {
                ++i;
            } else {
                inQuote = ! inQuote;
            }
        }
        else if ( ! inQuote && ((ch >= 0x0061 /*'a'*/ && ch <= 0x007A /*'z'*/)
                    || (ch >= 0x0041 /*'A'*/ && ch <= 0x005A /*'Z'*/))) {
            prevCh = ch;
            ++count;
        }
    }
    if ( count > 0 ) {
        // last item
        level = fgPatternCharToLevel[prevCh - PATTERN_CHAR_BASE];
            if ( fieldLevel <= level ) {
                return FALSE;
            }
    }
    return TRUE;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index