Comparing version 0.5.10 to 0.5.11
{ | ||
"name": "ssf", | ||
"version": "0.5.10", | ||
"version": "0.5.11", | ||
"author": "SheetJS", | ||
@@ -5,0 +5,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
11
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.5.10'; | ||
SSF.version = '0.5.11'; | ||
/* Options */ | ||
@@ -259,2 +259,7 @@ var opts_fmt = {}; | ||
} | ||
if((r = fmt.match(/^([?]+)([ ]?)\/([ ]?)([?]+)/))) { | ||
rr = Math.min(Math.max(r[1].length, r[4].length),7); | ||
ff = frac(aval, Math.pow(10,rr)-1, false); | ||
return sign + (ff[0]||(ff[1] ? "" : "0")) + (ff[1] ? pad(ff[1],rr," ") + r[2] + "/" + r[3] + rpad(ff[2],rr," "): fill(" ", 2*rr+1 + r[2].length + r[3].length)); | ||
} | ||
if((r = fmt.match(/^# ([?]+)([ ]?)\/([ ]?)([?]+)/))) { | ||
@@ -267,4 +272,2 @@ rr = Math.min(Math.max(r[1].length, r[4].length),7); | ||
case "0": case "#0": return Math.round(val); | ||
case "#.##": o = Math.round(val*100); | ||
return String(o/100).replace(/^([^\.]+)$/,"$1.").replace(/^0\.$/,"."); | ||
case "#,###": var x = commaify(String(Math.round(aval))); return x !== "0" ? sign + x : ""; | ||
@@ -314,3 +317,3 @@ default: | ||
/* falls through */ | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': case 'g': | ||
if(v < 0) return ""; | ||
@@ -317,0 +320,0 @@ if(!dt) dt = parse_date_code(v, opts); |
13
ssf.md
@@ -463,2 +463,7 @@ # SSF | ||
``` | ||
if((r = fmt.match(/^([?]+)([ ]?)\/([ ]?)([?]+)/))) { | ||
rr = Math.min(Math.max(r[1].length, r[4].length),7); | ||
ff = frac(aval, Math.pow(10,rr)-1, false); | ||
return sign + (ff[0]||(ff[1] ? "" : "0")) + (ff[1] ? pad(ff[1],rr," ") + r[2] + "/" + r[3] + rpad(ff[2],rr," "): fill(" ", 2*rr+1 + r[2].length + r[3].length)); | ||
} | ||
if((r = fmt.match(/^# ([?]+)([ ]?)\/([ ]?)([?]+)/))) { | ||
@@ -476,4 +481,2 @@ rr = Math.min(Math.max(r[1].length, r[4].length),7); | ||
case "0": case "#0": return Math.round(val); | ||
case "#.##": o = Math.round(val*100); | ||
return String(o/100).replace(/^([^\.]+)$/,"$1.").replace(/^0\.$/,"."); | ||
case "#,###": var x = commaify(String(Math.round(aval))); return x !== "0" ? sign + x : ""; | ||
@@ -544,3 +547,3 @@ ``` | ||
The date codes `m,d,y,h,s` are standard. There are some special formats like | ||
`e` (era year) that have different behaviors in Japanese/Chinese locales. | ||
`e / g` (era year) that have different behaviors in Japanese/Chinese locales. | ||
@@ -552,3 +555,3 @@ ``` | ||
/* falls through */ | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': case 'g': | ||
``` | ||
@@ -1018,3 +1021,3 @@ | ||
"name": "ssf", | ||
"version": "0.5.10", | ||
"version": "0.5.11", | ||
"author": "SheetJS", | ||
@@ -1021,0 +1024,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
@@ -102,2 +102,13 @@ [ | ||
[1, "??/??", " 1/1 "], | ||
[-1.2, "??/??", "- 6/5 "], | ||
[12.3, "??/??", "123/10"], | ||
[-12.34, "??/??", "-617/50"], | ||
[123.45, "??/??", "2469/20"], | ||
[-123.456, "??/??", "-7037/57"], | ||
[1234.567, "??/??", "119753/97"], | ||
[-1234.5678, "??/??", "-100000/81"], | ||
[12345.6789, "??/??", "1000000/81"], | ||
[-12345.67891, "??/??", "-1000000/81"], | ||
[0.3, "# ?/?", " 2/7"], | ||
@@ -104,0 +115,0 @@ [1.3, "# ?/?", "1 1/3"], |
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
106572
1952