diff --git a/package.json b/package.json index e1e3fab..ed33534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssf", - "version": "0.5.11", + "version": "0.5.12", "author": "SheetJS", "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", "keywords": [ "format", "sprintf", "spreadsheet" ], diff --git a/ssf.js b/ssf.js index 7bc50cf..d11e341 100644 --- a/ssf.js +++ b/ssf.js @@ -5,7 +5,7 @@ var _strrev = function(x) { return String(x).split("").reverse().join("");}; function fill(c,l) { return new Array(l+1).join(c); } function pad(v,d,c){var t=String(v);return t.length>=d?t:(fill(c||0,d-t.length)+t);} 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.11'; +SSF.version = '0.5.12'; /* Options */ var opts_fmt = {}; function fixopts(o){for(var y in opts_fmt) if(o[y]===undefined) o[y]=opts_fmt[y];} @@ -120,6 +120,10 @@ var parse_date_code = function parse_date_code(v,opts) { var dout=[], out={D:date, T:time, u:86400*(v-date)-time}; fixopts(opts = (opts||{})); if(opts.date1904) date += 1462; if(date > 2958465) return null; + if(out.u > .999) { + out.u = 0; + ++time; + } if(date === 60) {dout = [1900,2,29]; dow=3;} else if(date === 0) {dout = [1900,1,0]; dow=6;} else { diff --git a/ssf.md b/ssf.md index ca973f4..acc9b8a 100644 --- a/ssf.md +++ b/ssf.md @@ -293,6 +293,15 @@ Date codes beyond 12/31/9999 are invalid: if(date > 2958465) return null; ``` +Due to floating point issues, correct for subseconds: + +``` + if(out.u > .999) { + out.u = 0; + ++time; + } +``` + Due to a bug in Lotus 1-2-3 which was propagated by Excel and other variants, the year 1900 is recognized as a leap year. JS has no way of representing that abomination as a `Date`, so the easiest way is to store the data as a tuple. @@ -1014,7 +1023,7 @@ coveralls: ```json>package.json { "name": "ssf", - "version": "0.5.11", + "version": "0.5.12", "author": "SheetJS", "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", "keywords": [ "format", "sprintf", "spreadsheet" ],