Skip to content

Commit

Permalink
version bump 0.5.12: correcting for subseconds
Browse files Browse the repository at this point in the history
h/t @notatestuser

Fixes #5

Also fixes SheetJS/sheetjs#51
  • Loading branch information
SheetJSDev committed Mar 27, 2014
1 parent 4404d21 commit c428205
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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" ],
Expand Down
6 changes: 5 additions & 1 deletion ssf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];}
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion ssf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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" ],
Expand Down

0 comments on commit c428205

Please sign in to comment.