Comparing version 0.11.0 to 0.11.1
{ | ||
"name": "ssf", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"author": "sheetjs", | ||
@@ -5,0 +5,0 @@ "description": "Format data using ECMA-376 spreadsheet Format Codes", |
@@ -7,3 +7,3 @@ /* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */ | ||
var make_ssf = function make_ssf(SSF/*:SSFModule*/){ | ||
SSF.version = '0.11.0'; | ||
SSF.version = '0.11.1'; | ||
function _strrev(x/*:string*/)/*:string*/ { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; } | ||
@@ -75,3 +75,2 @@ function fill(c/*:string*/,l/*:number*/)/*:string*/ { var o = ""; while(o.length < l) o+=c; return o; } | ||
t[56]= '"上午/下午 "hh"時"mm"分"ss"秒 "'; | ||
t[65535]= 'General'; | ||
} | ||
@@ -81,2 +80,57 @@ | ||
init_table(table_fmt); | ||
/* Defaults determined by systematically testing in Excel 2019 */ | ||
/* These formats appear to default to other formats in the table */ | ||
var default_map/*:Array<number>*/ = []; | ||
var defi = 0; | ||
// 5 -> 37 ... 8 -> 40 | ||
for(defi = 5; defi <= 8; ++defi) default_map[defi] = 32 + defi; | ||
// 23 -> 0 ... 26 -> 0 | ||
for(defi = 23; defi <= 26; ++defi) default_map[defi] = 0; | ||
// 27 -> 14 ... 31 -> 14 | ||
for(defi = 27; defi <= 31; ++defi) default_map[defi] = 14; | ||
// 50 -> 14 ... 58 -> 14 | ||
for(defi = 50; defi <= 58; ++defi) default_map[defi] = 14; | ||
// 59 -> 1 ... 62 -> 4 | ||
for(defi = 59; defi <= 62; ++defi) default_map[defi] = defi - 58; | ||
// 67 -> 9 ... 68 -> 10 | ||
for(defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 58; | ||
// 72 -> 14 ... 75 -> 17 | ||
for(defi = 72; defi <= 75; ++defi) default_map[defi] = defi - 58; | ||
// 69 -> 12 ... 71 -> 14 | ||
for(defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 57; | ||
// 76 -> 20 ... 78 -> 22 | ||
for(defi = 76; defi <= 78; ++defi) default_map[defi] = defi - 56; | ||
// 79 -> 45 ... 81 -> 47 | ||
for(defi = 79; defi <= 81; ++defi) default_map[defi] = defi - 34; | ||
// 82 -> 0 ... 65536 -> 0 (omitted) | ||
/* These formats technically refer to Accounting formats with no equivalent */ | ||
var default_str/*:Array<string>*/ = []; | ||
// 5 -- Currency, 0 decimal, black negative | ||
default_str[5] = default_str[63] = '"$"#,##0_);\\("$"#,##0\\)'; | ||
// 6 -- Currency, 0 decimal, red negative | ||
default_str[6] = default_str[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)'; | ||
// 7 -- Currency, 2 decimal, black negative | ||
default_str[7] = default_str[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)'; | ||
// 8 -- Currency, 2 decimal, red negative | ||
default_str[8] = default_str[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)'; | ||
// 41 -- Accounting, 0 decimal, No Symbol | ||
default_str[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)'; | ||
// 42 -- Accounting, 0 decimal, $ Symbol | ||
default_str[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)'; | ||
// 43 -- Accounting, 2 decimal, No Symbol | ||
default_str[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)'; | ||
// 44 -- Accounting, 2 decimal, $ Symbol | ||
default_str[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'; | ||
function frac(x/*:number*/, D/*:number*/, mixed/*:?boolean*/)/*:Array<number>*/ { | ||
@@ -186,3 +240,10 @@ var sgn = x < 0 ? -1 : 1; | ||
SSF._general = general_fmt; | ||
function fix_hijri(/*::date, o*/) { return 0; } | ||
function fix_hijri(date/*:Date*/, o/*:[number, number, number]*/) { | ||
/* TODO: properly adjust y/m/d and */ | ||
o[0] -= 581; | ||
var dow = date.getDay(); | ||
if(date < 60) dow = (dow + 6) % 7; | ||
return dow; | ||
} | ||
var THAI_DIGITS = "\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59".split(""); | ||
/*jshint -W086 */ | ||
@@ -332,3 +393,6 @@ function write_date(type/*:number*/, fmt/*:string*/, val, ss0/*:?number*/)/*:string*/ { | ||
} | ||
function flr(val/*:number*/)/*:string*/ { if(val < 2147483647 && val > -2147483648) return ""+(val >= 0 ? (val|0) : (val-1|0)); return ""+Math.floor(val); } | ||
function flr(val/*:number*/)/*:string*/ { | ||
if(val < 2147483647 && val > -2147483648) return ""+(val >= 0 ? (val|0) : (val-1|0)); | ||
return ""+Math.floor(val); | ||
} | ||
function write_num_flt(type/*:string*/, fmt/*:string*/, val/*:number*/)/*:string*/ { | ||
@@ -556,3 +620,3 @@ if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) { | ||
SSF._split = split_fmt; | ||
var abstime = /\[[HhMmSs]*\]/; | ||
var abstime = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/; | ||
function fmt_is_date(fmt/*:string*/)/*:boolean*/ { | ||
@@ -573,5 +637,6 @@ var i = 0, /*cc = 0,*/ c = "", o = ""; | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': case 'g': return true; | ||
case 'A': case 'a': | ||
case 'A': case 'a': case '上': | ||
if(fmt.substr(i, 3).toUpperCase() === "A/P") return true; | ||
if(fmt.substr(i, 5).toUpperCase() === "AM/PM") return true; | ||
if(fmt.substr(i, 5).toUpperCase() === "上午/下午") return true; | ||
++i; break; | ||
@@ -633,3 +698,3 @@ case '[': | ||
out[out.length] = {t:c, v:o}; lst = c; break; | ||
case 'A': case 'a': | ||
case 'A': case 'a': case '上': | ||
var q={t:c, v:c}; | ||
@@ -639,2 +704,3 @@ if(dt==null) dt=parse_date_code(v, opts); | ||
else if(fmt.substr(i,5).toUpperCase() === "AM/PM") { if(dt!=null) q.v = dt.H >= 12 ? "PM" : "AM"; q.t = 'T'; i+=5; hr='h'; } | ||
else if(fmt.substr(i,5).toUpperCase() === "上午/下午") { if(dt!=null) q.v = dt.H >= 12 ? "下午" : "上午"; q.t = 'T'; i+=5; hr='h'; } | ||
else { q.t = "t"; ++i; } | ||
@@ -675,3 +741,3 @@ if(dt==null && q.t === 'T') return ""; | ||
case ' ': out[out.length] = {t:c, v:c}; ++i; break; | ||
case "$": out[out.length] = {t:'t', v:'$'}; ++i; break; | ||
case '$': out[out.length] = {t:'t', v:'$'}; ++i; break; | ||
default: | ||
@@ -682,2 +748,4 @@ if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt); | ||
} | ||
/* Scan for date/time parts */ | ||
var bt = 0, ss0 = 0, ssm; | ||
@@ -701,2 +769,3 @@ for(i=out.length-1, lst='t'; i >= 0; --i) { | ||
} | ||
/* time rounding depends on presence of minute / second / usec fields */ | ||
switch(bt) { | ||
@@ -716,2 +785,3 @@ case 0: break; | ||
} | ||
/* replace fields */ | ||
@@ -856,2 +926,4 @@ var nstr = "", jj; | ||
else sfmt = (o.table != null ? (o.table/*:any*/) : table_fmt)[fmt]; | ||
if(sfmt == null) sfmt = (o.table && o.table[default_map[fmt]]) || table_fmt[default_map[fmt]]; | ||
if(sfmt == null) sfmt = default_str[fmt] || "General"; | ||
break; | ||
@@ -858,0 +930,0 @@ } |
88
ssf.js
@@ -6,3 +6,3 @@ /* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */ | ||
var make_ssf = function make_ssf(SSF){ | ||
SSF.version = '0.11.0'; | ||
SSF.version = '0.11.1'; | ||
function _strrev(x) { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; } | ||
@@ -71,3 +71,2 @@ function fill(c,l) { var o = ""; while(o.length < l) o+=c; return o; } | ||
t[56]= '"上午/下午 "hh"時"mm"分"ss"秒 "'; | ||
t[65535]= 'General'; | ||
} | ||
@@ -77,2 +76,57 @@ | ||
init_table(table_fmt); | ||
/* Defaults determined by systematically testing in Excel 2019 */ | ||
/* These formats appear to default to other formats in the table */ | ||
var default_map = []; | ||
var defi = 0; | ||
// 5 -> 37 ... 8 -> 40 | ||
for(defi = 5; defi <= 8; ++defi) default_map[defi] = 32 + defi; | ||
// 23 -> 0 ... 26 -> 0 | ||
for(defi = 23; defi <= 26; ++defi) default_map[defi] = 0; | ||
// 27 -> 14 ... 31 -> 14 | ||
for(defi = 27; defi <= 31; ++defi) default_map[defi] = 14; | ||
// 50 -> 14 ... 58 -> 14 | ||
for(defi = 50; defi <= 58; ++defi) default_map[defi] = 14; | ||
// 59 -> 1 ... 62 -> 4 | ||
for(defi = 59; defi <= 62; ++defi) default_map[defi] = defi - 58; | ||
// 67 -> 9 ... 68 -> 10 | ||
for(defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 58; | ||
// 72 -> 14 ... 75 -> 17 | ||
for(defi = 72; defi <= 75; ++defi) default_map[defi] = defi - 58; | ||
// 69 -> 12 ... 71 -> 14 | ||
for(defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 57; | ||
// 76 -> 20 ... 78 -> 22 | ||
for(defi = 76; defi <= 78; ++defi) default_map[defi] = defi - 56; | ||
// 79 -> 45 ... 81 -> 47 | ||
for(defi = 79; defi <= 81; ++defi) default_map[defi] = defi - 34; | ||
// 82 -> 0 ... 65536 -> 0 (omitted) | ||
/* These formats technically refer to Accounting formats with no equivalent */ | ||
var default_str = []; | ||
// 5 -- Currency, 0 decimal, black negative | ||
default_str[5] = default_str[63] = '"$"#,##0_);\\("$"#,##0\\)'; | ||
// 6 -- Currency, 0 decimal, red negative | ||
default_str[6] = default_str[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)'; | ||
// 7 -- Currency, 2 decimal, black negative | ||
default_str[7] = default_str[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)'; | ||
// 8 -- Currency, 2 decimal, red negative | ||
default_str[8] = default_str[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)'; | ||
// 41 -- Accounting, 0 decimal, No Symbol | ||
default_str[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)'; | ||
// 42 -- Accounting, 0 decimal, $ Symbol | ||
default_str[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)'; | ||
// 43 -- Accounting, 2 decimal, No Symbol | ||
default_str[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)'; | ||
// 44 -- Accounting, 2 decimal, $ Symbol | ||
default_str[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'; | ||
function frac(x, D, mixed) { | ||
@@ -182,3 +236,10 @@ var sgn = x < 0 ? -1 : 1; | ||
SSF._general = general_fmt; | ||
function fix_hijri() { return 0; } | ||
function fix_hijri(date, o) { | ||
/* TODO: properly adjust y/m/d and */ | ||
o[0] -= 581; | ||
var dow = date.getDay(); | ||
if(date < 60) dow = (dow + 6) % 7; | ||
return dow; | ||
} | ||
var THAI_DIGITS = "\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59".split(""); | ||
/*jshint -W086 */ | ||
@@ -327,3 +388,6 @@ function write_date(type, fmt, val, ss0) { | ||
} | ||
function flr(val) { if(val < 2147483647 && val > -2147483648) return ""+(val >= 0 ? (val|0) : (val-1|0)); return ""+Math.floor(val); } | ||
function flr(val) { | ||
if(val < 2147483647 && val > -2147483648) return ""+(val >= 0 ? (val|0) : (val-1|0)); | ||
return ""+Math.floor(val); | ||
} | ||
function write_num_flt(type, fmt, val) { | ||
@@ -549,3 +613,3 @@ if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) { | ||
SSF._split = split_fmt; | ||
var abstime = /\[[HhMmSs]*\]/; | ||
var abstime = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/; | ||
function fmt_is_date(fmt) { | ||
@@ -566,5 +630,6 @@ var i = 0, /*cc = 0,*/ c = "", o = ""; | ||
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': case 'g': return true; | ||
case 'A': case 'a': | ||
case 'A': case 'a': case '上': | ||
if(fmt.substr(i, 3).toUpperCase() === "A/P") return true; | ||
if(fmt.substr(i, 5).toUpperCase() === "AM/PM") return true; | ||
if(fmt.substr(i, 5).toUpperCase() === "上午/下午") return true; | ||
++i; break; | ||
@@ -626,3 +691,3 @@ case '[': | ||
out[out.length] = {t:c, v:o}; lst = c; break; | ||
case 'A': case 'a': | ||
case 'A': case 'a': case '上': | ||
var q={t:c, v:c}; | ||
@@ -632,2 +697,3 @@ if(dt==null) dt=parse_date_code(v, opts); | ||
else if(fmt.substr(i,5).toUpperCase() === "AM/PM") { if(dt!=null) q.v = dt.H >= 12 ? "PM" : "AM"; q.t = 'T'; i+=5; hr='h'; } | ||
else if(fmt.substr(i,5).toUpperCase() === "上午/下午") { if(dt!=null) q.v = dt.H >= 12 ? "下午" : "上午"; q.t = 'T'; i+=5; hr='h'; } | ||
else { q.t = "t"; ++i; } | ||
@@ -668,3 +734,3 @@ if(dt==null && q.t === 'T') return ""; | ||
case ' ': out[out.length] = {t:c, v:c}; ++i; break; | ||
case "$": out[out.length] = {t:'t', v:'$'}; ++i; break; | ||
case '$': out[out.length] = {t:'t', v:'$'}; ++i; break; | ||
default: | ||
@@ -675,2 +741,4 @@ if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt); | ||
} | ||
/* Scan for date/time parts */ | ||
var bt = 0, ss0 = 0, ssm; | ||
@@ -694,2 +762,3 @@ for(i=out.length-1, lst='t'; i >= 0; --i) { | ||
} | ||
/* time rounding depends on presence of minute / second / usec fields */ | ||
switch(bt) { | ||
@@ -707,2 +776,3 @@ case 0: break; | ||
} | ||
/* replace fields */ | ||
@@ -846,2 +916,4 @@ var nstr = "", jj; | ||
else sfmt = (o.table != null ? (o.table) : table_fmt)[fmt]; | ||
if(sfmt == null) sfmt = (o.table && o.table[default_map[fmt]]) || table_fmt[default_map[fmt]]; | ||
if(sfmt == null) sfmt = default_str[fmt] || "General"; | ||
break; | ||
@@ -848,0 +920,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
220508
6718
0