docs: function formatValue(fmt, value) {
      var format = replace(fmt, /^\?/);
      if (isDate(value)) {
        var timezone, match;
  
        if (match = /^\[(([+-])(\d\d)(\d\d))\]\s*(.*)/.exec(format)) {
          timezone = match[1];
          value = dateAdd(value, 'minutes', getTimezone(match, 2, value));
          format = match[5];
        }
  
        return replace(format, /(\w)(\1*)(?:\[([^\]]+)\])?/g, function(s, placeholderChar, placeholderDigits, params) {
          var val = FORMAT_DATE_MAP[placeholderChar];
          if (val) {
            var d = value['get' + val[0]]();
            var optionArray = (params && params.split(','));
  
            if (isList(val[1]))
              d = (optionArray || val[1])[d];
            else
              d = val[1](d, optionArray, timezone);
            if (d != _null && !isString(d))
              d = pad(placeholderDigits.length+1, d);
            return d;
          }
          else
            return s;
        });
  
      }
      else
        return find(format.split(/\s*\|\s*/), function(fmtPart) {
          var match, numFmtOrResult;
          if (match = /^([<>]?)(=?)([^:]*?)\s*:\s*(.*)$/.exec(fmtPart)) {
            var cmpVal1 = value, cmpVal2 = +(match[3]);
            if (isNaN(cmpVal2) || !isNumber(cmpVal1)) {
              cmpVal1 = (cmpVal1==_null) ? "null" : toString(cmpVal1); // not ""+value, because undefined is treated as null here
              cmpVal2 = match[3];
            }
            if (match[1]) {
              if ((!match[2] && cmpVal1 == cmpVal2 ) ||
                  (match[1] == '<'  && cmpVal1 > cmpVal2)  ||
                  (match[1] == '>'  && cmpVal1 < cmpVal2))
                return _null;
            }
            else if (cmpVal1 != cmpVal2)
              return _null;
            numFmtOrResult = match[4];
          }
          else
            numFmtOrResult = fmtPart;
  
          if (isNumber(value))
            return numFmtOrResult.replace(/[0#](.*[0#])?/, function(numFmt) {
              var decimalFmt = /^([^.]+)(\.)([^.]+)$/.exec(numFmt) || /^([^,]+)(,)([^,]+)$/.exec(numFmt);
              var signed = value < 0 ? '-' : '';
              var numData = /(\d+)(\.(\d+))?/.exec((signed?-value:value).toFixed(decimalFmt ? decimalFmt[3].length:0));
              var preDecimalFmt = decimalFmt ? decimalFmt[1] : numFmt;
              var postDecimal = decimalFmt ? processNumCharTemplate(decimalFmt[3], replace(numData[3], /0+$/), true) : '';
  
              return 	(signed ? '-' : '') +
                      (preDecimalFmt == '#' ? numData[1] : processNumCharTemplate(preDecimalFmt, numData[1])) +
                      (postDecimal.length ? decimalFmt[2] : '') +
                      postDecimal;
            });
          else
            return numFmtOrResult;
        });
    }