How to prevent smart dates in the calendar bbcode?

AI-generated summary

Preventing Smart Dates in Calendar BBCode

Nacho_Caballero wants to display dates as the day of the week without showing the time when the date is yesterday, today, or tomorrow. The dddd format works for dates at least a week away, but not for dates within 48 hours.

Nacho_Caballero shared examples of the issue:

[date=2020-10-31 time=18:00:00 timezone="Europe/Madrid" format="dddd"]
[date=2020-11-01 time=18:00:00 timezone="Europe/Madrid" format="dddd"]
[date=2020-11-02 time=15:00:00 timezone="Europe/Madrid" format="dddd"]
[date=2020-11-03 time=15:00:00 timezone="Europe/Madrid" format="dddd"]

Slowhand provided a solution by adding calendar=off to the BBCode:

[date=2020-11-01 time=11:10:00 timezone="America/Chicago"calendar=off]

Nacho_Caballero thank Slowhand for sharing the solution and discovered additional options, including timezones, displayedTimezone, and countdown, in the Discourse local-dates test.

I would like to be able to show a date as a day of the week. Using dddd works if the date is at least a week away:

Saturday

[date=2025-11-01 time=18:00:00 timezone="Europe/Madrid" format="dddd"]

But if the date is yesterday or in 48 hours, the time appears along with yesterday/today/tomorrow:

- [date=2020-10-31 time=18:00:00 timezone="Europe/Madrid" format="dddd"]
- [date=2020-11-01 time=18:00:00 timezone="Europe/Madrid" format="dddd"]
- [date=2020-11-02 time=15:00:00 timezone="Europe/Madrid" format="dddd"]
- [date=2020-11-03 time=15:00:00 timezone="Europe/Madrid" format="dddd"]

Is there a way to prevent this smart behavior?

I asked this question a while ago in this thread

Short answer was to put in the words “calendar=off”

[ date=2020-11-01 time=11:10:00 timezone="America/Chicago"calendar=off ]

2020-11-01T17:10:00Z

Thank you so much for asking it (and sharing it). :blush:

I found the tests here:

https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/test/javascripts/lib/local-date-builder-test.js.es6#L304

I didn’t know there were all these other options: :sweat_smile:

  • timezones
  • displayedTimezone
  • countdown