Comparing version 0.6.3 to 0.6.4
{ | ||
"name": "ssf", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"author": "SheetJS", | ||
@@ -5,0 +5,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
14
ssf.js
@@ -8,3 +8,3 @@ /* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */ | ||
function rpad(v,d,c){var t=String(v);return t.length>=d?t:(t+fill(c||0,d-t.length));} | ||
SSF.version = '0.6.3'; | ||
SSF.version = '0.6.4'; | ||
/* Options */ | ||
@@ -267,11 +267,11 @@ var opts_fmt = {}; | ||
if((r = fmt.match(/^#,#*,#0/))) return write_num(type,fmt.replace(/^#,#*,/,""),val); | ||
if((r = fmt.match(/^([0#]+)-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/-/,""), val); | ||
if((r = fmt.match(/^([0#]+)\\?-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/[\\-]/g,""), val); | ||
return ff.substr(0,ff.length - r[2].length) + "-" + ff.substr(ff.length-r[2].length); | ||
} | ||
if((r = fmt.match(/^([0#]+)-([0#]+)-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/-/g,""), val); | ||
if((r = fmt.match(/^([0#]+)\\?-([0#]+)\\?-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/[\\-]/g,""), val); | ||
return ff.substr(0,ff.length - r[2].length - r[3].length) + "-" + ff.substr(ff.length-r[2].length - r[3].length, r[2].length) + "-" + ff.substr(ff.length-r[3].length); | ||
} | ||
if(fmt == "(###) ###-####") { | ||
if(fmt.match(/\(###\) ###\\?-####/)) { | ||
ff = write_num(type, "##########", val); | ||
@@ -375,3 +375,3 @@ return "(" + ff.substr(0,3) + ") " + ff.substr(3, 3) + "-" + ff.substr(6); | ||
case '0': case '#': case '.': | ||
o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) o += c; | ||
o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1 || c=='\\' && fmt[i+1] == "-" && "0#".indexOf(fmt[i+2])>-1) o += c; | ||
out.push({t:'n', v:o}); break; | ||
@@ -378,0 +378,0 @@ case '?': |
17
ssf.md
@@ -473,8 +473,8 @@ # SSF | ||
``` | ||
if((r = fmt.match(/^([0#]+)-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/-/,""), val); | ||
if((r = fmt.match(/^([0#]+)\\?-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/[\\-]/g,""), val); | ||
return ff.substr(0,ff.length - r[2].length) + "-" + ff.substr(ff.length-r[2].length); | ||
} | ||
if((r = fmt.match(/^([0#]+)-([0#]+)-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/-/g,""), val); | ||
if((r = fmt.match(/^([0#]+)\\?-([0#]+)\\?-([0#]+)$/))) { | ||
ff = write_num(type, fmt.replace(/[\\-]/g,""), val); | ||
return ff.substr(0,ff.length - r[2].length - r[3].length) + "-" + ff.substr(ff.length-r[2].length - r[3].length, r[2].length) + "-" + ff.substr(ff.length-r[3].length); | ||
@@ -488,3 +488,3 @@ } | ||
``` | ||
if(fmt == "(###) ###-####") { | ||
if(fmt.match(/\(###\) ###\\?-####/)) { | ||
ff = write_num(type, "##########", val); | ||
@@ -674,3 +674,4 @@ return "(" + ff.substr(0,3) + ") " + ff.substr(3, 3) + "-" + ff.substr(6); | ||
Number blocks (following the general pattern `[0#?][0#?.,E+-%]*`) are grouped together: | ||
Number blocks (following the general pattern `[0#?][0#?.,E+-%]*`) are grouped | ||
together. Literal hyphens are swallowed as well: | ||
@@ -680,3 +681,3 @@ ``` | ||
case '0': case '#': case '.': | ||
o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) o += c; | ||
o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1 || c=='\\' && fmt[i+1] == "-" && "0#".indexOf(fmt[i+2])>-1) o += c; | ||
out.push({t:'n', v:o}); break; | ||
@@ -1146,3 +1147,3 @@ | ||
"name": "ssf", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"author": "SheetJS", | ||
@@ -1149,0 +1150,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
@@ -76,3 +76,6 @@ [ | ||
["000-00-0000", [123456789, "123-45-6789"]], | ||
["00000\\-0000", [941051630, "94105-1630"]], | ||
["000\\-00\\-0000", [123456789, "123-45-6789"]], | ||
["[<=9999999]###-####;(###) ###-####", [8675309, "867-5309"],[2813308004, "(281) 330-8004"]], | ||
["[<=9999999]###\\-####;(###) ###\\-####", [8675309, "867-5309"],[2813308004, "(281) 330-8004"]], | ||
["[Red][<-25]General;[Blue][>25]General;[Green]General;[Yellow]General", [50, "50"],[26, "26"],[25,"25"],[1,"1"],[0,"0"],[-1,"-1"],[-25,"-25"],[-26,"26","#"],[-50,"50","#"], ["foo","foo"],["bar","bar"]], | ||
@@ -79,0 +82,0 @@ ["[Red][<=-25]General;[Blue][>=25]General;[Green]General;[Yellow]General", [50, "50"],[26, "26"],[25,"25"],[1,"1"],[0,"0"],[-1,"-1"],[-25,"-25"],[-26,"26","#"],[-50,"50","#"], ["foo","foo"],["bar","bar"]], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117044
2064