octoghost icon indicating copy to clipboard operation
octoghost copied to clipboard

Sometimes, other importers don't add dates to converted files. A small fix.

Open namanyayg opened this issue 10 years ago • 0 comments

I used WP -> Octopress before, and it didn't import all dates. This led to the JSON having no 'created by' which is required by Ghost to import posts.

I wrote a small fix here:

...
                            post_tag_id = post_tag_id + 1
                    else:
                        pass
            else:
                raise Exception('Unexpected exception!')

// Get times if none found
createdAt = post.get('created_at', int(time.mktime(datetime.datetime.strptime(markdown_file[7:17] + ' 00:00', "%Y-%m-%d %H:%M").timetuple()) * 1e3))

    post["created_at"] = createdAt
    post["updated_at"] = createdAt
    post["published_at"] = createdAt

This works due to the fact that filenames themselves have some part of the date - It parses them and assigns the time at 12 o' clock of that day.

It's an ugly solution since I'm pathetic at python, but should work.

namanyayg avatar Jul 17 '14 12:07 namanyayg