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
This commit is contained in:
SheetJS 2014-03-27 11:38:12 -07:00
parent 4404d216c2
commit c428205723
3 changed files with 16 additions and 3 deletions

View File

@ -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" ],

6
ssf.js
View File

@ -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 {

11
ssf.md
View File

@ -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" ],