Off-by-one error showing the date in timeline-ago?

AI-generated summary

A discussion is taking place about an off-by-one error in the timeline-ago feature of Discourse. danielcompton reports that the start date in the timeline is incorrect, showing May 26 instead of May 25. The issue persists even after switching timezones. The problem is suspected to be related to the position code in the topic-timeline.js.es6 file. However, codinghorror points out that the topic in question is massively obsolete, which might be a factor. danielcompton clarifies that the timestamp appears to be localized, as they see a different date than codinghorror.

When I view https://meta.discourse.org/t/admin-actions-goes-behind-the-titlebar/118649 (can’t post the link as I’m a new user) (or many other Discourse posts) I see this:

The start date in the timeline is May 25, but the date shown in the timeline-ago component when at 1/5 is May 26.

My computer (macOS 10.14.6, Safari 12.1.2) is in the Pacific/Auckland timezone. When I switch my computer to America/Los_Angeles I see the same issues, but all of the dates are one day backwards.

The timeline-ago date is set at discourse/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 at 9a17b196365a1f9a5e88a0f8a36e2e35c56b39bc · discourse/discourse · GitHub, and uses timelineDate to format the date. This is used to set the start-date and now-date, so it’s not likely to be the source of the issue.

From reading the code, position (L151-154) looks like it might be causing the issue, but I could be wrong, I’m brand new to the Discourse codebase and Ember.

1 Like

Topic is massively obsolete and thus deleted, but the date on first post is

<span title="May 24, 2019 11:14 pm" data-time="1558764857214" data-format="tiny" class="relative-date">May 24</span>

I think that is a localised timestamp? I see

<span title="May 25, 2019 6:14 pm" data-time="1558764857214" data-format="tiny" class="relative-date">May 25</span>

I’ve edited the post to make it clearer what the issue is.