Version bump 0.2.1: date1904 support

date1904 flag now propagated to SSF
This commit is contained in:
SheetJS 2013-04-03 19:03:39 -04:00
parent 0d8fedfe1f
commit a0b73e3d4f
4 changed files with 13 additions and 9 deletions

@ -131,8 +131,8 @@ var write_date = function(type, fmt, val) {
case 'ss': return pad(val.S, 2);
default: throw 'bad second format: ' + fmt;
}; break;
/* TODO: handle the ECMA spec format ee -> yy */
case 'e': { return val.y; } break;
/* TODO: handle the ECMA spec format ee -> yy */
case 'e': { return val.y; } break;
case 'A': return (val.h>=12 ? 'P' : 'A') + fmt.substr(1);
default: throw 'bad format type ' + type + ' in ' + fmt;
}

@ -120,7 +120,7 @@ function parsexmltag(tag) {
var strs = {}; // shared strings
var styles = {}; // shared styles
var _ssfopts = {}; // spreadsheet formatting options
/* 18.3 Worksheets */
function parseSheet(data) {
@ -183,7 +183,7 @@ function parseSheet(data) {
p.raw = p.v;
p.rawt = p.t;
try {
p.v = SSF.format(cf.numFmtId,p.v);
p.v = SSF.format(cf.numFmtId,p.v,_ssfopts);
p.t = 'str';
} catch(e) { p.v = p.raw; }
}
@ -440,6 +440,8 @@ function parseWB(data) {
wb.WBView.forEach(function(w){for(var z in WBViewDef) if(null==w[z]) w[z]=WBViewDef[z]; });
wb.Sheets.forEach(function(w){for(var z in SheetDef) if(null==w[z]) w[z]=SheetDef[z]; });
_ssfopts.date1904 = wb.WBProps.date1904;
return wb;
}

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.2.0",
"version": "0.2.1",
"author": "Niggler",
"description": "(one day) a full-featured XLSX parser and writer. For now, primitive parser",
"keywords": [

10
xlsx.js

@ -133,8 +133,8 @@ var write_date = function(type, fmt, val) {
case 'ss': return pad(val.S, 2);
default: throw 'bad second format: ' + fmt;
}; break;
/* TODO: handle the ECMA spec format ee -> yy */
case 'e': { return val.y; } break;
/* TODO: handle the ECMA spec format ee -> yy */
case 'e': { return val.y; } break;
case 'A': return (val.h>=12 ? 'P' : 'A') + fmt.substr(1);
default: throw 'bad format type ' + type + ' in ' + fmt;
}
@ -344,7 +344,7 @@ function parsexmltag(tag) {
var strs = {}; // shared strings
var styles = {}; // shared styles
var _ssfopts = {}; // spreadsheet formatting options
/* 18.3 Worksheets */
function parseSheet(data) {
@ -407,7 +407,7 @@ function parseSheet(data) {
p.raw = p.v;
p.rawt = p.t;
try {
p.v = SSF.format(cf.numFmtId,p.v);
p.v = SSF.format(cf.numFmtId,p.v,_ssfopts);
p.t = 'str';
} catch(e) { p.v = p.raw; }
}
@ -664,6 +664,8 @@ function parseWB(data) {
wb.WBView.forEach(function(w){for(var z in WBViewDef) if(null==w[z]) w[z]=WBViewDef[z]; });
wb.Sheets.forEach(function(w){for(var z in SheetDef) if(null==w[z]) w[z]=SheetDef[z]; });
_ssfopts.date1904 = wb.WBProps.date1904;
return wb;
}