Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fixed silent failure when no post_date_gmt was present in "post" item #8
When trying to convert my wordpres .xml I at first got a silent failure. No output was produced nor were any warnings displayed.
The problem and fix can be tested on the following input .xml example.
With this fix the output is
which can successfully be imported into ghost.
I did assume that if post_date_gmt and post_date were missing we were out of luck. However we usually have a pubDate field as well which can be parsed as well. But in my case where the post_data_gmt and post_date were missing the pubDates were in a weird format seen below:
I got the original wordpress.xml from when i used the export function on a squarespace trial account. It should not make a difference, but just in case Im leaving that tidbit here at the end in case someone else has problems and is searching for an answer.
Testcases added in ecf12b4. I added two new items to the same test .xml. I also checked for their existence besides doing simple checks for the fallbacks working as intended (to some degree). I used year 0 BC as discussed. The values that we are checking for for the two dates (year 0 and 2011) were checked against http://www.epochconverter.com/.