python-wordpress-xmlrpc
python-wordpress-xmlrpc copied to clipboard
How to properly work with dates?
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
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.
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.