lib/kissy/5.0.0-alpha.3/lib/build/date/format.js
function (dateStr) {
            var calendar = /**@type {KISSY.Date.Gregorian}
             @ignore*/
                new GregorianCalendar(this.timezoneOffset, this.locale), i, j, tmp = {}, obeyCount = false, dateStrLen = dateStr.length, errorIndex = -1, startIndex = 0, oldStartIndex = 0, pattern = this.pattern, len = pattern.length;
            loopPattern: {
                for (i = 0; errorIndex < 0 && i < len; i++) {
                    var comp = pattern[i], text, textLen;
                    oldStartIndex = startIndex;
                    if (text = comp.text) {
                        textLen = text.length;
                        if (textLen + startIndex > dateStrLen) {
                            errorIndex = startIndex;
                        } else {
                            for (j = 0; j < textLen; j++) {
                                if (text.charAt(j) !== dateStr.charAt(j + startIndex)) {
                                    errorIndex = startIndex;
                                    break loopPattern;
                                }
                            }
                            startIndex += textLen;
                        }
                    } else if ('field' in comp) {
                        obeyCount = false;
                        var nextComp = pattern[i + 1];
                        if (nextComp) {
                            if ('field' in nextComp) {
                                obeyCount = true;
                            } else {
                                var c = nextComp.text.charAt(0);
                                if (c >= '0' && c <= '9') {
                                    obeyCount = true;
                                }
                            }
                        }
                        startIndex = parseField(calendar, dateStr, startIndex, comp.field, comp.count, this.locale, obeyCount, tmp);
                        if (startIndex === oldStartIndex) {
                            errorIndex = startIndex;
                        }
                    }
                }
            }
            if (errorIndex >= 0) {
                logger.error('error when parsing date');
                logger.error(dateStr);
                logger.error(dateStr.substring(0, errorIndex) + '^');
                return undefined;
            }
            return calendar;
        }
function (dateStr) {
            var calendar = /**@type {KISSY.Date.Gregorian}
             @ignore*/
                new GregorianCalendar(this.timezoneOffset, this.locale), i, j, tmp = {}, obeyCount = false, dateStrLen = dateStr.length, errorIndex = -1, startIndex = 0, oldStartIndex = 0, pattern = this.pattern, len = pattern.length;
            loopPattern: {
                for (i = 0; errorIndex < 0 && i < len; i++) {
                    var comp = pattern[i], text, textLen;
                    oldStartIndex = startIndex;
                    if (text = comp.text) {
                        textLen = text.length;
                        if (textLen + startIndex > dateStrLen) {
                            errorIndex = startIndex;
                        } else {
                            for (j = 0; j < textLen; j++) {
                                if (text.charAt(j) !== dateStr.charAt(j + startIndex)) {
                                    errorIndex = startIndex;
                                    break loopPattern;
                                }
                            }
                            startIndex += textLen;
                        }
                    } else if ('field' in comp) {
                        obeyCount = false;
                        var nextComp = pattern[i + 1];
                        if (nextComp) {
                            if ('field' in nextComp) {
                                obeyCount = true;
                            } else {
                                var c = nextComp.text.charAt(0);
                                if (c >= '0' && c <= '9') {
                                    obeyCount = true;
                                }
                            }
                        }
                        startIndex = parseField(calendar, dateStr, startIndex, comp.field, comp.count, this.locale, obeyCount, tmp);
                        if (startIndex === oldStartIndex) {
                            errorIndex = startIndex;
                        }
                    }
                }
            }
            if (errorIndex >= 0) {
                logger.error('error when parsing date');
                logger.error(dateStr);
                logger.error(dateStr.substring(0, errorIndex) + '^');
                return undefined;
            }
            return calendar;
        }
function ( dateStr ) { var calendar = /**@type {KISSY.Date.Gregorian}
             @ignore*/ new GregorianCalendar ( this . timezoneOffset , this . locale ) , i , j , tmp = { } , obeyCount = false , dateStrLen = dateStr . length , errorIndex = - 1 , startIndex = 0 , oldStartIndex = 0 , pattern = this . pattern , len = pattern . length ; loopPattern : { for ( i = 0 ; errorIndex < 0 && i < len ; i ++ ) { var comp = pattern [ i ] , text , textLen ; oldStartIndex = startIndex ; if ( text = comp . text ) { textLen = text . length ; if ( textLen + startIndex > dateStrLen ) { errorIndex = startIndex ; } else { for ( j = 0 ; j < textLen ; j ++ ) { if ( text . charAt ( j ) !== dateStr . charAt ( j + startIndex ) ) { errorIndex = startIndex ; break loopPattern ; } } startIndex += textLen ; } } else if ( 'field' in comp ) { obeyCount = false ; var nextComp = pattern [ i + 1 ] ; if ( nextComp ) { if ( 'field' in nextComp ) { obeyCount = true ; } else { var c = nextComp . text . charAt ( 0 ) ; if ( c >= '0' && c <= '9' ) { obeyCount = true ; } } } startIndex = parseField ( calendar , dateStr , startIndex , comp . field , comp . count , this . locale , obeyCount , tmp ) ; if ( startIndex === oldStartIndex ) { errorIndex = startIndex ; } } } } if ( errorIndex >= 0 ) { logger . error ( 'error when parsing date' ) ; logger . error ( dateStr ) ; logger . error ( dateStr . substring ( 0 , errorIndex ) + '^' ) ; return undefined ; } return calendar ; }
parse a formatted string of GregorianDate instance according to specified pattern
@param {String} dateStr formatted string of GregorianDate
@returns {KISSY.Date.Gregorian}
parse a formatted string of GregorianDate instance according to specified pattern