python-wordpress-xmlrpc icon indicating copy to clipboard operation
python-wordpress-xmlrpc copied to clipboard

How to properly work with dates?

Open macedd opened this issue 11 years ago • 2 comments

I've found some flaws when dealing with dates and RPC.

Can you expose how do you work with them?

Currently I'm converting all dates to UTC prior to sending to WordPress

macedd avatar Feb 10 '14 23:02 macedd

If you mean what Python types to use, you want to use the wordpress_xmlrpc.compat.xmlrpc_client.DateTime type; see the docs at http://docs.python.org/2/library/xmlrpclib.html#datetime-objects

If you mean which fields on the WordPressPost object to set, that's a bit more subtle. My recommendation is to only use post_date_gmt with a GMT/UTC datetime, as that's the only guaranteed way to get the value you desire. If you use the plain post_date field, it will get converted on the server based on user timezone settings, which may be different than the local timezone on the client running this library.

I'll use this issue to track adding proper documentation around dates. If I didn't fully answer your question, please let me know.

maxcutler avatar Feb 12 '14 06:02 maxcutler

Yes, thanks, I ended using the Post.date on GMT. Its also a good idea to put some docs on the field mappings and how they are treated by the library.

macedd avatar Feb 24 '14 21:02 macedd