From c4282057233ba479c96bc5abb8baa89f77f6e3e4 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Thu, 27 Mar 2014 11:38:12 -0700 Subject: [PATCH] version bump 0.5.12: correcting for subseconds h/t @notatestuser Fixes https://github.com/SheetJS/ssf/issues/5 Also fixes https://github.com/SheetJS/js-xlsx/issues/51 --- package.json | 2 +- ssf.js | 6 +++++- ssf.md | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) 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" ],