Here you can find the source of fromJSON(json)
Date.fromJSON = function(json) { try{ //from w w w . j av a 2 s . co m if (json.length == 10){ parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(json); return new Date(Date.UTC(parts[1],parts[2]-1,parts[3],0,0,0)); }else{ parts = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*Z$/.exec(json); return new Date(Date.UTC(parts[1],parts[2]-1,parts[3],parts[4],parts[5],parts[6])); } } catch(e){ return null; } };
Number.prototype.fromOADate = function () var jO = new Date(((this - 25569) * 86400000)); var tz = jO.getTimezoneOffset(); return new Date(((this - 25569 + (tz / (60 * 24))) * 86400000)); };
Date.fromYYYYMMDD = function(tmp) { return new Date( parseInt(tmp.substr(0, 4).replace(/^0+/, "")) , parseInt(tmp.substr(4, 2).replace(/^0+/, ""))-1 , parseInt(tmp.substr(6, 2).replace(/^0+/, "")) );