dcramer / wp-lifestream

Lifestreaming plugin for Wordpress
http://forums.lifestrm.com/index.php
122 stars 30 forks source link

Timezone Issues fix #82

Closed tonyduckles closed 11 years ago

tonyduckles commented 12 years ago

This is my stab at fixing the timezone support in wp-lifestream.

Once upon a time, it looks like Wordpress ran in local time, but for the past few years/versions Wordpress is forcibly running in GMT/UTC time. wp-lifestream was always rendering timestamps without a specific timezone offset given, so timestamps were always displayed in UTC time rather than the local timezone that the user configured Wordpress to show timestamps in.

I've created a wrapper function ($lifestream->date_format) which times in a timestamp format-string and a timestamp (in UTC time), internally gets the configured Wordpress timezone, and then returned a formatted timestamp with the correct timezone offset. This provides a nice central abstraction.

I've been running with these changes on my personal site for well-over a year now. The changes here are only quasi "linked". All the data in the Lifestream tables is uniformly stored in UTC time, so everything works fine when we start trying to display those times based on the configured timezone offset. If I remember right, the trouble is with the "child" Wordpress post records ("lvevent" type), which were getting created with a UTC-based timestamp rather than the local-time like they expected. I think I ended-up manually deleting all the lsevent-type rows from my wp_posts table and then using the "Fix missing posts" on the Lifestream Maintenance settings page to call the updated $lifestream->create_post_for_event() tag to make sure to create the "child" WP post row with the same timestamp as the Lifestream event row. But that is really only important if you care about the "child" page, i.e. if you try to click-through a Lifestream event to go to the WP post page for that event.

px commented 12 years ago

I pulled the changes, and they work well in my tree