Automattic / liveblog

Liveblogging done right. Using WordPress.
https://wordpress.org/plugins/liveblog/
311 stars 122 forks source link

Front end incorrectly renders times in DST #608

Open paulschreiber opened 5 years ago

paulschreiber commented 5 years ago

If a live blog occurs during DST (say, October 1), but is read at a later time (say, December 1), all of the timestamps will be off by one hour.

Database shows (correct):

comment_ID: 4
comment_post_ID: 58568
comment_author: 
comment_author_email: 
comment_author_url: 
comment_author_IP: 
comment_date: 2014-10-29 20:07:05
comment_date_gmt: 2014-10-30 00:07:05

JSON shows (correct):

"timestamp": 1414627433,

Website shows (incorrect):

7:03 PM

Expected:

8:03 PM

Related code: https://github.com/Automattic/liveblog/blob/master/src/react/utils/utils.js#L155

Problem appears to be: JavaScript code using the UTC offset for today (liveblog_settings.utc_offset) (-300, 5 hours, EST). However, in October, when the post was published the offset was (-240, 4 hours, EDT).

formattedTime() should not take offset as a parameter. It should take timezone_string as parameter.

paulschreiber commented 5 years ago

Moment.js docs: https://momentjs.com/timezone/