diff --git a/examples/timeline/dataHandling/dataSerialization.html b/examples/timeline/dataHandling/dataSerialization.html index 291f9ad0..79b6aebf 100644 --- a/examples/timeline/dataHandling/dataSerialization.html +++ b/examples/timeline/dataHandling/dataSerialization.html @@ -35,12 +35,12 @@ @@ -89,9 +89,10 @@ function saveData() { // get the data from the DataSet + // // Note that we specify the output type of the fields start and end - // as ISODate, which is safely serializable. Other serializable types - // are Number (unix timestamp) or ASPDate. + // as "ISODate", which is safely serializable. Other serializable types + // are "Number" (unix timestamp), "ASPDate" or "String" (without timezone!). // // Alternatively, it is possible to configure the DataSet to convert // the output automatically to ISODates like: @@ -118,4 +119,4 @@ loadData(); - \ No newline at end of file + diff --git a/lib/util.js b/lib/util.js index f9506a6a..9ced5862 100644 --- a/lib/util.js +++ b/lib/util.js @@ -392,8 +392,11 @@ exports.convert = function (object, type) { case 'number': case 'Number': - return Number(object.valueOf()); - + if (!isNaN(Date.parse(object))) { + return moment(object).valueOf(); + } else { + return Number(object.valueOf()); + } case 'string': case 'String': return String(object); @@ -467,7 +470,7 @@ exports.convert = function (object, type) { return new Date(Number(match[1])).toISOString(); // parse number } else { - return new Date(object).toISOString(); // parse string + return moment(object).format(); // ISO 8601 } } else { @@ -1477,4 +1480,4 @@ exports.getScrollBarWidth = function () { document.body.removeChild (outer); return (w1 - w2); -}; \ No newline at end of file +};