Lines Matching refs:fmt

570 function SSF_write_date(type/*:number*/, fmt/*:string*/, val, ss0/*:?number*/)/*:string*/ {  argument
577 switch(fmt.length) {
582 switch(fmt.length) {
583 case 1: case 2: out = val.m; outl = fmt.length; break;
589 switch(fmt.length) {
590 case 1: case 2: out = val.d; outl = fmt.length; break;
595 switch(fmt.length) {
596 case 1: case 2: out = 1+(val.H+11)%12; outl = fmt.length; break;
597 default: throw 'bad hour format: ' + fmt;
600 switch(fmt.length) {
601 case 1: case 2: out = val.H; outl = fmt.length; break;
602 default: throw 'bad hour format: ' + fmt;
605 switch(fmt.length) {
606 case 1: case 2: out = val.M; outl = fmt.length; break;
607 default: throw 'bad minute format: ' + fmt;
610 …if(fmt != 's' && fmt != 'ss' && fmt != '.0' && fmt != '.00' && fmt != '.000') throw 'bad second fo…
611 if(val.u === 0 && (fmt == "s" || fmt == "ss")) return pad0(val.S, fmt.length);
617 if(fmt === 's') return ss === 0 ? "0" : ""+ss/tt;
619 if(fmt === 'ss') return o.substr(0,2);
620 return "." + o.substr(2,fmt.length-1);
622 switch(fmt) {
626 default: throw 'bad abstime format: ' + fmt;
627 } outl = fmt.length === 3 ? 1 : 2; break;
646 function write_num_pct(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/{ argument
647 var sfmt = fmt.replace(pct1,""), mul = fmt.length - sfmt.length;
651 function write_num_cm(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/{ argument
652 var idx = fmt.length - 1;
653 while(fmt.charCodeAt(idx-1) === 44) --idx;
654 return write_num(type, fmt.substr(0,idx), val / Math.pow(10,3*(fmt.length-idx)));
657 function write_num_exp(fmt/*:string*/, val/*:number*/)/*:string*/{ argument
659 var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
660 if(fmt.match(/^#+0.0E\+0$/)) {
662 else if(val < 0) return "-" + write_num_exp(fmt, -val);
663 var period = fmt.indexOf("."); if(period === -1) period=fmt.indexOf('E');
679 …if(fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0,o.length-1) + "0" + o.charAt(o.lengt…
680 if(fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/,"e");
721 function write_num_flt(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/ { argument
722 if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
723 var ffmt = fmt.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");
727 if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
728 if(fmt.indexOf('%') !== -1) return write_num_pct(type, fmt, val);
729 if(fmt.indexOf('E') !== -1) return write_num_exp(fmt, val);
730 if(fmt.charCodeAt(0) === 36) return "$"+write_num_flt(type,fmt.substr(fmt.charAt(1)==' '?2:1),val);
733 if(fmt.match(/^00+$/)) return sign + pad0r(aval,fmt.length);
734 if(fmt.match(/^[#?]+$/)) {
736 return o.length > fmt.length ? o : hashq(fmt.substr(0,fmt.length-o.length)) + o;
738 if((r = fmt.match(frac1))) return write_num_f1(r, aval, sign);
739 if(fmt.match(/^#+0+$/)) return sign + pad0r(aval,fmt.length - fmt.indexOf("0"));
740 if((r = fmt.match(dec1))) {
742 return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./,".");
744 fmt = fmt.replace(/^#+([0.])/, "$1");
745 if((r = fmt.match(/^(0*)\.(#*)$/))) {
748 if((r = fmt.match(/^#{1,3},##0(\.?)$/))) return sign + commaify(pad0r(aval,0));
749 if((r = fmt.match(/^#,##0\.([#0]*0)$/))) {
750 …return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(""+(Math.floor(val) + carry(val, …
752 if((r = fmt.match(/^#,#*,#0/))) return write_num_flt(type,fmt.replace(/^#,#*,/,""),val);
753 if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/))) {
754 o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g,""), val));
756 …return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o.cha…
758 if(fmt.match(phone)) {
763 if((r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))) {
775 if((r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))) {
780 if((r = fmt.match(/^[#0?]+$/))) {
782 if(fmt.length <= o.length) return o;
783 return hashq(fmt.substr(0,fmt.length-o.length)) + o;
785 if((r = fmt.match(/^([#0?]+)\.([#0]+)$/))) {
788 var lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
789 return hashq(fmt.substr(0,lres) + o + fmt.substr(fmt.length-rres));
791 if((r = fmt.match(/^00,000\.([#0]*0)$/))) {
793 …return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/,"0…
795 switch(fmt) {
804 throw new Error("unsupported format |" + fmt + "|");
806 function write_num_cm2(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/{ argument
807 var idx = fmt.length - 1;
808 while(fmt.charCodeAt(idx-1) === 44) --idx;
809 return write_num(type, fmt.substr(0,idx), val / Math.pow(10,3*(fmt.length-idx)));
811 function write_num_pct2(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/{ argument
812 var sfmt = fmt.replace(pct1,""), mul = fmt.length - sfmt.length;
815 function write_num_exp2(fmt/*:string*/, val/*:number*/)/*:string*/{ argument
817 var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
818 if(fmt.match(/^#+0.0E\+0$/)) {
820 else if(val < 0) return "-" + write_num_exp2(fmt, -val);
821 var period = fmt.indexOf("."); if(period === -1) period=fmt.indexOf('E');
833 …if(fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0,o.length-1) + "0" + o.charAt(o.lengt…
834 if(fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/,"e");
837 function write_num_int(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/ { argument
838 if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
839 var ffmt = fmt.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");
843 if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
844 if(fmt.indexOf('%') !== -1) return write_num_pct2(type, fmt, val);
845 if(fmt.indexOf('E') !== -1) return write_num_exp2(fmt, val);
846 if(fmt.charCodeAt(0) === 36) return "$"+write_num_int(type,fmt.substr(fmt.charAt(1)==' '?2:1),val);
849 if(fmt.match(/^00+$/)) return sign + pad0(aval,fmt.length);
850 if(fmt.match(/^[#?]+$/)) {
852 return o.length > fmt.length ? o : hashq(fmt.substr(0,fmt.length-o.length)) + o;
854 if((r = fmt.match(frac1))) return write_num_f2(r, aval, sign);
855 if(fmt.match(/^#+0+$/)) return sign + pad0(aval,fmt.length - fmt.indexOf("0"));
856 if((r = fmt.match(dec1))) {
862 return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./,".");
864 fmt = fmt.replace(/^#+([0.])/, "$1");
865 if((r = fmt.match(/^(0*)\.(#*)$/))) {
868 if((r = fmt.match(/^#{1,3},##0(\.?)$/))) return sign + commaify((""+aval));
869 if((r = fmt.match(/^#,##0\.([#0]*0)$/))) {
870 …return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify((""+val)) + "." + fill('0',r[1].l…
872 if((r = fmt.match(/^#,#*,#0/))) return write_num_int(type,fmt.replace(/^#,#*,/,""),val);
873 if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/))) {
874 o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g,""), val));
876 …return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o.cha…
878 if(fmt.match(phone)) {
883 if((r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))) {
895 if((r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))) {
900 if((r = fmt.match(/^[#0?]+$/))) {
902 if(fmt.length <= o.length) return o;
903 return hashq(fmt.substr(0,fmt.length-o.length)) + o;
905 if((r = fmt.match(/^([#0]+)\.([#0]+)$/))) {
908 var lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
909 return hashq(fmt.substr(0,lres) + o + fmt.substr(fmt.length-rres));
911 if((r = fmt.match(/^00,000\.([#0]*0)$/))) {
912 …return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify(""+val).replace(/^\d,\d{3}$/,"0$&…
914 switch(fmt) {
919 …if(fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0,fmt.lastIndexOf(".")), val) + ha…
921 throw new Error("unsupported format |" + fmt + "|");
923 function write_num(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/ { argument
924 return (val|0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
926 function SSF_split_fmt(fmt/*:string*/)/*:Array<string>*/ { argument
929 for(var i = 0, j = 0; i < fmt.length; ++i) switch((/*cc=*/fmt.charCodeAt(i))) {
935 out[out.length] = fmt.substr(j,i-j);
938 out[out.length] = fmt.substr(j);
939 if(in_str === true) throw new Error("Format |" + fmt + "| unterminated string ");
944 function fmt_is_date(fmt/*:string*/)/*:boolean*/ { argument
946 while(i < fmt.length) {
947 switch((c = fmt.charAt(i))) {
948 case 'G': if(SSF_isgeneral(fmt, i)) i+= 6; i++; break;
949 case '"': for(;(/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;){/*empty*/} ++i; break;
954 if(fmt.charAt(i+1) === "1" || fmt.charAt(i+1) === "2") return true;
960 if(fmt.substr(i, 3).toUpperCase() === "A/P") return true;
961 if(fmt.substr(i, 5).toUpperCase() === "AM/PM") return true;
962 if(fmt.substr(i, 5).toUpperCase() === "上午/下午") return true;
966 while(fmt.charAt(i++) !== ']' && i < fmt.length) o += fmt.charAt(i);
972 …while(i < fmt.length && ("0#?.,E+-%".indexOf(c=fmt.charAt(++i)) > -1 || (c=='\\' && fmt.charAt(i+1…
974 case '?': while(fmt.charAt(++i) === c){/* empty */} break;
975 case '*': ++i; if(fmt.charAt(i) == ' ' || fmt.charAt(i) == '*') ++i; break;
978 while(i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1){/* empty */} break;
986 function eval_fmt(fmt/*:string*/, v/*:any*/, opts/*:any*/, flen/*:number*/) { argument
990 while(i < fmt.length) {
991 switch((c = fmt.charAt(i))) {
993 if(!SSF_isgeneral(fmt, i)) throw new Error('unrecognized character ' + c + ' in ' +fmt);
996 for(o="";(cc=fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) o += String.fromCharCode(cc);
998 case '\\': var w = fmt.charAt(++i), t = (w === "(" || w === ")") ? w : 't';
1004 if(fmt.charAt(i+1) === "1" || fmt.charAt(i+1) === "2") {
1005 … if(dt==null) { dt=SSF_parse_date_code(v, opts, fmt.charAt(i+1) === "2"); if(dt==null) return ""; }
1006 out[out.length] = {t:'X', v:fmt.substr(i,2)}; lst = c; i+=2; break;
1015 o = c; while(++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o+=c;
1022 …if(fmt.substr(i, 3).toUpperCase() === "A/P") { if(dt!=null) q.v = dt.H >= 12 ? fmt.charAt(i+2) : c…
1023 …else if(fmt.substr(i,5).toUpperCase() === "AM/PM") { if(dt!=null) q.v = dt.H >= 12 ? "PM" : "AM"; …
1024 …else if(fmt.substr(i,5).toUpperCase() === "上午/下午") { if(dt!=null) q.v = dt.H >= 12 ? "下午" : "上午"; …
1030 while(fmt.charAt(i++) !== ']' && i < fmt.length) o += fmt.charAt(i);
1038 if(!fmt_is_date(fmt)) out[out.length] = {t:'t',v:o};
1044 o = c; while(++i < fmt.length && (c=fmt.charAt(i)) === "0") o += c;
1049 o = c; while(++i < fmt.length && "0#?.,E+-%".indexOf(c=fmt.charAt(i)) > -1) o += c;
1052 o = c; while(fmt.charAt(++i) === c) o+=c;
1054 case '*': ++i; if(fmt.charAt(i) == ' ' || fmt.charAt(i) == '*') ++i; break; // **
1057 o = c; while(i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) o+=fmt.charAt(i);
1062 …fijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
1209 var fmt = SSF_split_fmt(f);
1210 var l = fmt.length, lat = fmt[l-1].indexOf("@");
1212 if(fmt.length > 4) throw new Error("cannot find right format for |" + fmt.join("|") + "|");
1213 if(typeof v !== "number") return [4, fmt.length === 4 || lat>-1?fmt[fmt.length-1]:"@"];
1214 switch(fmt.length) {
1215 …case 1: fmt = lat>-1 ? ["General", "General", "General", fmt[0]] : [fmt[0], fmt[0], fmt[0], "@"]; …
1216 case 2: fmt = lat>-1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], "@"]; break;
1217 case 3: fmt = lat>-1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], "@"]; break;
1220 var ff = v > 0 ? fmt[0] : v < 0 ? fmt[1] : fmt[2];
1221 if(fmt[0].indexOf("[") === -1 && fmt[1].indexOf("[") === -1) return [l, ff];
1222 if(fmt[0].match(/\[[=<>]/) != null || fmt[1].match(/\[[=<>]/) != null) {
1223 var m1 = fmt[0].match(cfregex2);
1224 var m2 = fmt[1].match(cfregex2);
1225 …return chkcond(v, m1) ? [l, fmt[0]] : chkcond(v, m2) ? [l, fmt[1]] : [l, fmt[m1 != null && m2 != n…
1229 function SSF_format(fmt/*:string|number*/,v/*:any*/,o/*:?any*/) { argument
1232 switch(typeof fmt) {
1234 if(fmt == "m/d/yy" && o.dateNF) sfmt = o.dateNF;
1235 else sfmt = fmt;
1238 if(fmt == 14 && o.dateNF) sfmt = o.dateNF;
1239 else sfmt = (o.table != null ? (o.table/*:any*/) : table_fmt)[fmt];
1240 …sfmt == null) sfmt = (o.table && o.table[SSF_default_map[fmt]]) || table_fmt[SSF_default_map[fmt]];
1241 if(sfmt == null) sfmt = SSF_default_str[fmt] || "General";
1252 function SSF_load(fmt/*:string*/, idx/*:?number*/)/*:number*/ { argument
1259 if(table_fmt[i] == fmt) { idx = i; break; }
1265 table_fmt[idx] = fmt;
1330 var fmt = typeof dateNF == "number" ? table_fmt[dateNF] : dateNF;
1331 fmt = fmt.replace(dateNFregex, "(\\d+)");
1332 return new RegExp("^" + fmt + "$");
1359 function SSF__load(fmt, idx) { argument
1360 return SSF_load(bad_formats[fmt] || fmt, idx);
7362 return { fmt:cf };
7570 var o = {fmt:cf, env:env, len:lcb, data:blob.slice(blob.l,blob.l+lcb)}; property in parse_ImData.o
17936 var fmt = XLMLFormatMap[format] || unescapexml(format);
17937 if(fmt === "General") return SSF_general(value);
17938 return SSF_format(fmt, value);
19630 case 0x041e /* Format */: { /* val = [id, fmt] */
23580 var fmt = ver >= 5 ? nfmt : ofmt;
23583 var dstyle = ((_a = fmt[7]) == null ? void 0 : _a[0]) ? parse_varint49(fmt[7][0].data) : -1;
23586 var dmin = ((_b = fmt[15]) == null ? void 0 : _b[0]) ? parse_varint49(fmt[15][0].data) : -1;
23587 var dmax = ((_c = fmt[16]) == null ? void 0 : _c[0]) ? parse_varint49(fmt[16][0].data) : -1;
23588 var auto = ((_d = fmt[40]) == null ? void 0 : _d[0]) ? parse_varint49(fmt[40][0].data) : -1;
26322 function cell_set_number_format(cell/*:Cell*/, fmt/*:string|number*/) { argument
26323 cell.z = fmt;