Problem with dates parsing
See original GitHub issueI have a xlsx file with different date formats, all of which are interpreted as Date type by Excel (2016, Mac). I need to parse these kind of values to native js date objects, but unfortunately js-xlsx interprets them as Number type, see following outputs. I am using js-xlsx v0.8.0 with node v0.12.2. Is it expected behaviour ? How can I parse it to native date objects ?
Outputs:
{ '!ref': 'A1:A12',
A1: { t: 's', v: 'Dates', r: '<t>Dates</t>', h: 'Dates', w: 'Dates' },
A2: { t: 'n', v: 41365, w: 'April-13' },
A3: { t: 'n', v: 41367, w: '03-Apr-13' },
A4: { t: 'n', v: 41409, w: '5/15/13' },
A5: { t: 'n', v: 41412, w: '5/18' },
A6: { t: 'n', v: 41434, w: 'June 9, 2013' },
A7: { t: 'n', v: 41538, w: '9/21/13 12:00 AM' },
A8: { t: 'n', v: 41466, w: 'J-13' },
A9: { t: 'n', v: 41516, w: '30-Aug-13' },
A10: { t: 'n', v: 41835, w: '15-Jul' },
A11:
{ t: 's',
v: '29-02-14',
r: '<t>29-02-14</t>',
h: '29-02-14',
w: '29-02-14' } }
Output of sheet_to_json with raw = true :
[ { Dates: 41365 },
{ Dates: 41367 },
{ Dates: 41409 },
{ Dates: 41412 },
{ Dates: 41434 },
{ Dates: 41538 },
{ Dates: 41466 },
{ Dates: 41516 },
{ Dates: 41835 },
{ Dates: '29-02-14' } ]
Issue Analytics
- State:
- Created 8 years ago
- Comments:6
Top Results From Across the Web
Problems with Date.parse() function - Designing Pipelines
Hi, I have a problem with the Date.parse () function. I cannot convert a String to date, the format of my string is...
Read more >Why does Date.parse give incorrect results? - Stack Overflow
According to http://blog.dygraphs.com/2012/03/javascript-and-dates-what-mess.html the format "yyyy/mm/dd" solves the usual problems.
Read more >Common mistakes in date/time formatting and parsing
Locale / culture issues · The calendar system used (e.g. the Gregorian calendar vs an Islamic calendar) · The “standard” formats used (e.g....
Read more >The Many Quirks of Javascript Dates - Fjolt
It is strongly advised to not parse date strings. Before the ECMAScript 5 specification, how Date parsed string dates was never defined, and ......
Read more >Error 'failed to parse date' for Date Time ... - Salesforce Help
Valid formatting for Date/Time fields in the API are documented in the following resources:Format the 'Date' and 'Date Time' data in a CSV ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
var utc_value = Math.floor(your_number- 25569) * 86400; var date_info = new Date(utc_value * 1000); var month = parseInt(date_info.getMonth()) + 1; newDate = date_info.getFullYear() + “/” + month + “/” + date_info.getDate();
@andrevenancio Excel stores timestamps as a real number representing the number of days since 1 January 1900. 25569 is the number of days between 1 January 1900 and 1 January 1970, which is what we need to convert to a UNIX timestamp that can be used for Date.