A platform for community discussion. Free, open, simple.
FIX: compute correct date with local time (#34623)
Joffrey JAFFEUXb636cdcbe649
diff --git a/app/assets/javascripts/discourse/app/lib/load-rrule.js b/app/assets/javascripts/discourse/app/lib/load-rrule.jsnew file mode 100644index 00000000000..e5fbef0a0bf--- /dev/null+++ b/app/assets/javascripts/discourse/app/lib/load-rrule.js@@ -0,0 +1,7 @@+import { waitForPromise } from "@ember/test-waiters";++export default async function loadRRule() {+ const promise = import("discourse/static/rrule-bundle");+ waitForPromise(promise);+ return await promise;+}diff --git a/app/assets/javascripts/discourse/app/lib/local-dates.js b/app/assets/javascripts/discourse/app/lib/local-dates.jsindex 65ec52d322f..c4792aba01e 100644--- a/app/assets/javascripts/discourse/app/lib/local-dates.js+++ b/app/assets/javascripts/discourse/app/lib/local-dates.js@@ -1,4 +1,4 @@-export function applyLocalDates(dates, siteSettings) {+export function applyLocalDates(dates, siteSettings, timezone) {if (!siteSettings.discourse_local_dates_enabled) {return;}@@ -7,5 +7,5 @@ export function applyLocalDates(dates, siteSettings) {"discourse/plugins/discourse-local-dates/initializers/discourse-local-dates").applyLocalDates;- _applyLocalDates(dates, siteSettings);+ _applyLocalDates(dates, siteSettings, timezone);}diff --git a/app/assets/javascripts/discourse/app/static/rrule-bundle.js b/app/assets/javascripts/discourse/app/static/rrule-bundle.jsnew file mode 100644index 00000000000..ad9649a4eac--- /dev/null+++ b/app/assets/javascripts/discourse/app/static/rrule-bundle.js@@ -0,0 +1 @@+export { rrulestr } from "rrule";diff --git a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb b/plugins/discourse-calendar/app/models/discourse_post_event/event.rbindex 8d7d27d55f1..8a27163d47b 100644--- a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb+++ b/plugins/discourse-calendar/app/models/discourse_post_event/event.rb@@ -403,14 +403,15 @@ module DiscoursePostEventnext_starts_at = calculate_next_recurring_datereturn nil unless next_starts_at- next_ends_at = original_ends_at ? next_starts_at + event_duration : nil+ event_duration = original_ends_at ? original_ends_at - original_starts_at : 3600+ next_ends_at = next_starts_at + event_duration[next_starts_at, next_ends_at]enddef duration- return nil unless starts_at && ends_at+ return nil unless original_starts_at- duration_seconds = (ends_at - starts_at).to_i+ duration_seconds = original_ends_at ? original_ends_at - original_starts_at : 3600hours = (duration_seconds / 3600)minutes = ((duration_seconds % 3600) / 60)seconds = (duration_seconds % 60)@@ -418,6 +419,10 @@ module DiscoursePostEventsprintf("%02d:%02d:%02d", hours, minutes, seconds)end+ def rrule_timezone+ timezone || "UTC"+ end+privatedef dates_changed?@@ -461,18 +466,17 @@ module DiscoursePostEventenddef calculate_next_recurring_date+ timezone_starts_at = original_starts_at.in_time_zone(timezone)+ timezone_recurrence_until = recurrence_until&.in_time_zone(timezone)+RRuleGenerator.generate(- starts_at: original_starts_at.in_time_zone(timezone),- timezone: timezone,+ starts_at: timezone_starts_at,+ timezone: rrule_timezone,recurrence: recurrence,- recurrence_until: recurrence_until,- dtstart: original_starts_at.in_time_zone(timezone),+ recurrence_until: timezone_recurrence_until,+ dtstart: timezone_starts_at,).firstend-- def event_duration- original_ends_at - original_starts_at- endendenddiff --git a/plugins/discourse-calendar/app/serializers/discourse_post_event/basic_event_serializer.rb b/plugins/discourse-calendar/app/serializers/discourse_post_event/basic_event_serializer.rbindex 4e9f61d2c8c..9aa706b4369 100644--- a/plugins/discourse-calendar/app/serializers/discourse_post_event/basic_event_serializer.rb+++ b/plugins/discourse-calendar/app/serializers/discourse_post_event/basic_event_serializer.rb@@ -38,42 +38,70 @@ module DiscoursePostEventdef rrulereturn nil unless include_rrule?- # Use the original event time (same as the frontend display) for rrule generationtimezone_starts_at = object.original_starts_at.in_time_zone(object.timezone)timezone_recurrence_until = object.recurrence_until&.in_time_zone(object.timezone)RRuleGenerator.generate_string(starts_at: timezone_starts_at,- timezone: object.timezone,+ timezone: object.rrule_timezone,recurrence: object.recurrence,recurrence_until: timezone_recurrence_until,dtstart: timezone_starts_at,+ show_local_time: object.show_local_time,)enddef starts_at- # For recurring events, use UTC to match RRULE- # For non-recurring events, use the event's timezone- if object.recurring?- object.original_starts_at&.in_time_zone(object.timezone)+ if object.recurring? && object.recurrence_until.present? &&+ object.recurrence_until < Time.current+ return nil+ end++ if object.show_local_time+ timezone_time = object.original_starts_at&.in_time_zone(object.timezone)+ timezone_time&.strftime("%Y-%m-%dT%H:%M:%S")else- object.starts_at&.in_time_zone(object.timezone)+ if object.recurring?+ timezone_time = object.original_starts_at&.in_time_zone(object.timezone)+ timezone_time&.iso8601(3)+ else+ timezone_time = object.starts_at&.in_time_zone(object.timezone)+ timezone_time&.iso8601(3)+ endendenddef ends_at- if object.recurring?- object.original_ends_at&.in_time_zone(object.timezone) ||- (- object.original_starts_at &&- object.original_starts_at.in_time_zone(object.timezone) + 1.hour- )+ if object.recurring? && object.recurrence_until.present? &&+ object.recurrence_until < Time.current+ return nil+ end++ if object.show_local_time+ ends_at =+ object.original_ends_at ||+ (object.original_starts_at && object.original_starts_at + 1.hour)+ timezone_ends_at = ends_at&.in_time_zone(object.timezone)+ timezone_ends_at&.strftime("%Y-%m-%dT%H:%M:%S")else- if object.ends_at- object.ends_at&.in_time_zone(object.timezone)+ if object.recurring?+ ends_at =+ object.original_ends_at ||+ (object.original_starts_at && object.original_starts_at + 1.hour)+ timezone_ends_at = ends_at&.in_time_zone(object.timezone)+ timezone_ends_at&.iso8601(3)else- base_starts_at = object.starts_at&.in_time_zone(object.timezone)- base_starts_at ? (base_starts_at + 1.hour) : nil+ if object.ends_at+ timezone_ends_at = object.ends_at&.in_time_zone(object.timezone)+ timezone_ends_at&.iso8601(3)+ else+ base_starts_at = object.starts_at&.in_time_zone(object.timezone)+ if base_starts_at+ (base_starts_at + 1.hour).iso8601(3)+ else+ nil+ end+ endendendenddiff --git a/plugins/discourse-calendar/app/serializers/discourse_post_event/event_serializer.rb b/plugins/discourse-calendar/app/serializers/discourse_post_event/event_serializer.rbindex b035e88c55d..c298cfa287c 100644--- a/plugins/discourse-calendar/app/serializers/discourse_post_event/event_serializer.rb+++ b/plugins/discourse-calendar/app/serializers/discourse_post_event/event_serializer.rb@@ -1,15 +1,11 @@# frozen_string_literal: truemodule DiscoursePostEvent- class EventSerializer < ApplicationSerializer+ class EventSerializer < BasicEventSerializerattributes :can_act_on_discourse_post_eventattributes :can_update_attendance- attributes :category_idattributes :creatorattributes :custom_fields- attributes :duration- attributes :ends_at- attributes :idattributes :is_closedattributes :is_expiredattributes :is_ongoing@@ -25,18 +21,14 @@ module DiscoursePostEventattributes :remindersattributes :sample_inviteesattributes :should_display_invitees- attributes :starts_atattributes :statsattributes :status- attributes :timezone- attributes :show_local_timeattributes :urlattributes :descriptionattributes :locationattributes :watching_inviteeattributes :chat_enabledattributes :channel- attributes :rruledef channel::Chat::ChannelSerializer.new(object.chat_channel, root: false, scope:)@@ -90,20 +82,6 @@ module DiscoursePostEventEvent.statuses[object.status]end- # lightweight post object containing- # only needed info for client- def post- {- id: object.post.id,- post_number: object.post.post_number,- url: object.post.url,- topic: {- id: object.post.topic.id,- title: object.post.topic.title,- },- }- end-def can_update_attendancescope.current_user && object.can_user_update_attendance(scope.current_user)end@@ -134,38 +112,8 @@ module DiscoursePostEvent(object.private? && object.raw_invitees.count > 0)end- def category_id- object.post.topic.category_id- end-def include_url?object.url.present?end-- def include_rrule?- object.recurring?- end-- def rrule- RRuleGenerator.generate_string(- starts_at: object.original_starts_at.in_time_zone(object.timezone),- timezone: object.timezone,- recurrence: object.recurrence,- recurrence_until: object.recurrence_until&.in_time_zone(object.timezone),- dtstart: object.original_starts_at.in_time_zone(object.timezone),- )- end-- def duration- object.duration- end-- def include_duration?- object.duration.present?- end-- def ends_at- object.ends_at || (object.starts_at ? object.starts_at + 1.hour : nil)- endendenddiff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/dates.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/dates.gjsindex 5248a9f653e..c4fd68568a2 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/dates.gjs+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/dates.gjs@@ -2,37 +2,46 @@ import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";import { action } from "@ember/object";import didInsert from "@ember/render-modifiers/modifiers/did-insert";-import { next, schedule } from "@ember/runloop";+import { schedule } from "@ember/runloop";import { service } from "@ember/service";import { htmlSafe } from "@ember/template";import icon from "discourse/helpers/d-icon";+import discourseLater from "discourse/lib/later";+import loadRRule from "discourse/lib/load-rrule";import { applyLocalDates } from "discourse/lib/local-dates";import { cook } from "discourse/lib/text";export default class DiscoursePostEventDates extends Component {@service siteSettings;+ @service currentUser;@tracked htmlDates = "";- get startsAt() {- return moment(this.args.event.startsAt).tz(this.timezone);+ get timezone() {+ return this.args.event.timezone || "UTC";}- get endsAt() {+ get startsAt() {return (- this.args.event.endsAt && moment(this.args.event.endsAt).tz(this.timezone)+ this.args.currentEventStart ??+ moment(this.args.event.startsAt).tz(this.timezone));}- get timezone() {- return this.args.event.timezone || "UTC";+ get endsAt() {+ const currentEventEnd = this.args.currentEventEnd;+ const eventEndsAt = this.args.event.endsAt;++ return (+ currentEventEnd ??+ (eventEndsAt ? moment(eventEndsAt).tz(this.timezone) : null)+ );}get startsAtFormat() {- return this._buildFormat(this.startsAt, {- includeYear: !this.isSameYear(this.startsAt),- includeTime: this.hasTime(this.startsAt) || this.isSingleDayEvent,- });+ const includeYear = !this.isSameYear(this.startsAt);+ const includeTime = this.hasTime(this.startsAt) || this.isSingleDayEvent;+ return this._buildFormat(this.startsAt, { includeYear, includeTime });}get endsAtFormat() {@@ -40,12 +49,12 @@ export default class DiscoursePostEventDates extends Component {return "LT";}- return this._buildFormat(this.endsAt, {- includeYear:- !this.isSameYear(this.endsAt) ||- !this.isSameYear(this.endsAt, this.startsAt),- includeTime: this.hasTime(this.endsAt),- });+ const endsAt = this.endsAt;+ const includeYear =+ !this.isSameYear(endsAt) || !this.isSameYear(endsAt, this.startsAt);+ const includeTime = this.hasTime(endsAt);++ return this._buildFormat(endsAt, { includeYear, includeTime });}_buildFormat(date, { includeYear, includeTime }) {@@ -67,22 +76,21 @@ export default class DiscoursePostEventDates extends Component {get datesBBCode() {const dates = [];- dates.push(- this.buildDateBBCode({- date: this.startsAt,- format: this.startsAtFormat,- range: !!this.endsAt && "from",- })- );+ const startDate = this.buildDateBBCode({+ date: this.startsAt,+ format: this.startsAtFormat,+ range: !!this.endsAt && "from",+ });++ dates.push(startDate);if (this.endsAt) {- dates.push(- this.buildDateBBCode({- date: this.endsAt,- format: this.endsAtFormat,- range: "to",- })- );+ const endDate = this.buildDateBBCode({+ date: this.endsAt,+ format: this.endsAtFormat,+ range: "to",+ });+ dates.push(endDate);}return dates;@@ -101,7 +109,7 @@ export default class DiscoursePostEventDates extends Component {date: date.format("YYYY-MM-DD"),time: date.format("HH:mm"),format,- timezone: this.timezone,+ timezone: date.tz(),postId: this.args.event.id,};@@ -126,28 +134,35 @@ export default class DiscoursePostEventDates extends Component {return;}+ this.rrule = await loadRRule();+if (this.siteSettings.discourse_local_dates_enabled) {- const result = await cook(this.datesBBCode.join("<span> → </span>"));+ const bbcode = this.datesBBCode.join("<span> → </span>");+ const result = await cook(bbcode);this.htmlDates = htmlSafe(result.toString());- next(() => {+ // doesn’t work reliably without discourseLater+ discourseLater(() => {schedule("afterRender", () => {if (this.isDestroying || this.isDestroyed) {return;}+ const localDateElements = element.querySelectorAll(+ `[data-post-id="${this.args.event.id}"].discourse-local-date`+ );applyLocalDates(- element.querySelectorAll(- `[data-post-id="${this.args.event.id}"].discourse-local-date`- ),- this.siteSettings+ localDateElements,+ this.siteSettings,+ this.currentUser?.user_option?.timezone);});});} else {let dates = `${this.startsAt.format(this.startsAtFormat)}`;if (this.endsAt) {- dates += ` → ${moment(this.endsAt).format(this.endsAtFormat)}`;+ const endFormatted = moment(this.endsAt).format(this.endsAtFormat);+ dates += ` → ${endFormatted}`;}this.htmlDates = htmlSafe(dates);}diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjsindex 601954e63b7..6b042da7947 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs@@ -1,5 +1,6 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { action } from "@ember/object";import { service } from "@ember/service";import { modifier } from "ember-modifier";import AsyncContent from "discourse/components/async-content";@@ -11,6 +12,7 @@ import replaceEmoji from "discourse/helpers/replace-emoji";import routeAction from "discourse/helpers/route-action";import { popupAjaxError } from "discourse/lib/ajax-error";import { bind } from "discourse/lib/decorators";+import loadRRule from "discourse/lib/load-rrule";import ChatChannel from "./chat-channel";import Creator from "./creator";import Dates from "./dates";@@ -42,6 +44,7 @@ export default class DiscoursePostEvent extends Component {@service messageBus;@tracked event = this.args.event;+ @tracked rrule;setupMessageBus = modifier(() => {const path = `/discourse-post-event/${this.event.post.topic.id}`;@@ -53,24 +56,94 @@ export default class DiscoursePostEvent extends Component {return () => this.messageBus.unsubscribe(path);});- get withDescription() {- return this.args.withDescription ?? true;+ constructor() {+ super(...arguments);++ this.loadRRule();+ }++ get currentEventEnd() {+ if (!this.event.duration) {+ return this.currentEventStart.clone().add(1, "hour");+ }++ const [hours, minutes, seconds] = this.event.duration+ .split(":")+ .map(Number);+ const totalSeconds = hours * 3600 + minutes * 60 + seconds;++ return this.currentEventStart.clone().add(totalSeconds, "seconds");}- get localStartsAtTime() {- let time = moment(this.event.startsAt);- if (this.event.showLocalTime && this.event.timezone) {- time = time.tz(this.event.timezone);+ get currentEventStart() {+ let start = this.event.startsAt;++ if (this.event.rrule) {+ if (this.args.currentEventStart) {+ if (this.event.showLocalTime && this.event.timezone) {+ const fullCalendarDate = this.args.currentEventStart;+ const fullCalendarMoment = moment(fullCalendarDate);+ const originalEventMoment = moment.tz(+ this.event.startsAt,+ this.event.timezone+ );++ // Create a new moment with the FullCalendar date but the original event time+ const eventMoment = moment.tz(+ [+ fullCalendarMoment.year(),+ fullCalendarMoment.month(),+ fullCalendarMoment.date(),+ originalEventMoment.hour(),+ originalEventMoment.minute(),+ originalEventMoment.second(),+ ],+ this.event.timezone+ );++ start = eventMoment;+ } else {+ start = this.args.currentEventStart;+ }+ } else {+ const { rrulestr } = this.rrule;+ const rule = rrulestr(this.event.rrule);+ const dtstart = moment().subtract(23, "hours").toDate();+ start = rule.after(dtstart);+ }+ }++ let result;+ if (this.event.showLocalTime) {+ if (this.event.rrule) {+ // If start is already a moment object, use it directly+ if (moment.isMoment(start)) {+ result = start;+ } else {+ result = moment.utc(start).tz(this.event.timezone || "UTC", true);+ }+ } else {+ result = moment.tz(start, this.event.timezone || "UTC");+ }+ } else {+ result = moment+ .utc(start)+ .tz(this.currentUser?.user_option?.timezone || moment.tz.guess());}- return time;++ return result;+ }++ get withDescription() {+ return this.args.withDescription ?? true;}get startsAtMonth() {- return this.localStartsAtTime.format("MMM");+ return this.currentEventStart.format("MMM");}get startsAtDay() {- return this.localStartsAtTime.format("D");+ return this.currentEventStart.format("D");}get eventName() {@@ -97,6 +170,11 @@ export default class DiscoursePostEvent extends Component {return this.event.isExpired && this.event.recurrence;}+ @action+ async loadRRule() {+ this.rrule = await loadRRule();+ }+@bindasync loadEvent() {if (this.event) {@@ -117,109 +195,117 @@ export default class DiscoursePostEvent extends Component {<template><AsyncContent @asyncData={{this.loadEvent}}><:content as |event|>- <div class="discourse-post-event">- <div class="discourse-post-event-widget">- {{#if event}}- <header class="event-header" {{this.setupMessageBus}}>- <div class="event-date">- <div class="month">- {{#if this.expiredAndRecurring}}- -- {{else}}- {{this.startsAtMonth}}- {{/if}}- </div>- <div class="day">- {{#if this.expiredAndRecurring}}- -- {{else}}- {{this.startsAtDay}}- {{/if}}+ {{#if this.rrule}}+ <div class="discourse-post-event">+ <div class="discourse-post-event-widget">+ {{#if event}}+ <header class="event-header" {{this.setupMessageBus}}>+ <div class="event-date">+ <div class="month">+ {{#if this.expiredAndRecurring}}+ -+ {{else}}+ {{this.startsAtMonth}}+ {{/if}}+ </div>+ <div class="day">+ {{#if this.expiredAndRecurring}}+ -+ {{else}}+ {{this.startsAtDay}}+ {{/if}}+ </div></div>- </div>- <div class="event-info">- <span class="name">- {{#if @linkToPost}}- <a- href={{event.post.url}}- rel="noopener noreferrer"- >{{replaceEmoji this.eventName}}</a>- {{else}}- {{replaceEmoji this.eventName}}- {{/if}}- </span>- <div class="status-and-creators">- <PluginOutlet- @name="discourse-post-event-status-and-creators"- @outletArgs={{lazyHash- event=event- Separator=StatusSeparator- Status=(component EventStatus event=event)- Creator=(component Creator user=event.creator)- }}- >- <EventStatus @event={{event}} />- <StatusSeparator />- <Creator @user={{event.creator}} />- </PluginOutlet>+ <div class="event-info">+ <span class="name">+ {{#if @linkToPost}}+ <a+ href={{event.post.url}}+ rel="noopener noreferrer"+ >{{replaceEmoji this.eventName}}</a>+ {{else}}+ {{replaceEmoji this.eventName}}+ {{/if}}+ </span>+ <div class="status-and-creators">+ <PluginOutlet+ @name="discourse-post-event-status-and-creators"+ @outletArgs={{lazyHash+ event=event+ Separator=StatusSeparator+ Status=(component EventStatus event=event)+ Creator=(component Creator user=event.creator)+ }}+ >+ <EventStatus @event={{event}} />+ <StatusSeparator />+ <Creator @user={{event.creator}} />+ </PluginOutlet>+ </div></div>- </div>-- <MoreMenu- @event={{event}}- @isStandaloneEvent={{this.isStandaloneEvent}}- @composePrivateMessage={{routeAction "composePrivateMessage"}}- />-- {{#if @onClose}}- <DButton- class="btn-small"- @icon="xmark"- @action={{@onClose}}++ <MoreMenu+ @event={{event}}+ @isStandaloneEvent={{this.isStandaloneEvent}}+ @composePrivateMessage={{routeAction+ "composePrivateMessage"+ }}/>- {{/if}}- </header>-- <PluginOutlet- @name="discourse-post-event-info"- @outletArgs={{lazyHash- event=event- Section=(component InfoSection event=event)- Url=(component Url url=event.url)- Description=(component- Description description=event.description- )- Location=(component Location location=event.location)- Dates=(component- Dates++ {{#if @onClose}}+ <DButton+ class="btn-small discourse-post-event-close"+ @icon="xmark"+ @action={{@onClose}}+ />+ {{/if}}+ </header>++ <PluginOutlet+ @name="discourse-post-event-info"+ @outletArgs={{lazyHashevent=event- expiredAndRecurring=this.expiredAndRecurring- )- Invitees=(component Invitees event=event)- Status=(component Status event=event)- ChatChannel=(component ChatChannel event=event)- }}- >- <Dates- @event={{event}}- @expiredAndRecurring={{this.expiredAndRecurring}}- />- <Location @location={{event.location}} />- <Url @url={{event.url}} />- <ChatChannel @event={{event}} />- <Invitees @event={{event}} />-- {{#if this.withDescription}}- <Description @description={{event.description}} />- {{/if}}-- {{#if @event.canUpdateAttendance}}- <Status @event={{event}} />- {{/if}}- </PluginOutlet>- {{/if}}+ Section=(component InfoSection event=event)+ Url=(component Url url=event.url)+ Description=(component+ Description description=event.description+ )+ Location=(component Location location=event.location)+ Dates=(component+ Dates+ event=event+ expiredAndRecurring=this.expiredAndRecurring+ currentEventStart=this.currentEventStart+ currentEventEnd=this.currentEventEnd+ )+ Invitees=(component Invitees event=event)+ Status=(component Status event=event)+ ChatChannel=(component ChatChannel event=event)+ }}+ >+ <Dates+ @event={{event}}+ @expiredAndRecurring={{this.expiredAndRecurring}}+ @currentEventStart={{this.currentEventStart}}+ @currentEventEnd={{this.currentEventEnd}}+ />+ <Location @location={{event.location}} />+ <Url @url={{event.url}} />+ <ChatChannel @event={{event}} />+ <Invitees @event={{event}} />++ {{#if this.withDescription}}+ <Description @description={{event.description}} />+ {{/if}}++ {{#if @event.canUpdateAttendance}}+ <Status @event={{event}} />+ {{/if}}+ </PluginOutlet>+ {{/if}}+ </div></div>- </div>+ {{/if}}</:content><:loading><div class="discourse-post-event-loader">diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjsindex 7ef2970a1d5..918b4b335a1 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs@@ -21,6 +21,7 @@ const PostEventMenu = <template>@eventId={{@data.eventId}}@onClose={{@data.onClose}}@withDescription={{false}}+ @currentEventStart={{@data.currentEventStart}}/></template>;@@ -106,6 +107,7 @@ export default class FullCalendar extends Component {modalForMobile: true,maxWidth: 500,data: {+ currentEventStart: event.start,eventId: postEvent.id,onClose: () => {this.menu.getByIdentifier("post-event-menu")?.close?.();diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjsindex 6df8233ef42..481a969b3ce 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/upcoming-events-calendar.gjs@@ -19,6 +19,7 @@ export default class UpcomingEventsCalendar extends Component {_isInitializing = true;_isViewChanging = false;+ _lastNavigationTime = 0;get customButtons() {return {@@ -150,12 +151,22 @@ export default class UpcomingEventsCalendar extends Component {if (isViewChanged) {this._isViewChanging = true;+ let navYear = currentYear;+ let navMonth = currentMonth;+ let navDay = currentDay;++ if (view === "month") {+ navYear = currentYear;+ navMonth = currentMonth;+ navDay = 1;+ }+this.router.replaceWith(this.router.currentRouteName,view,- currentYear,- currentMonth,- currentDay+ navYear,+ navMonth,+ navDay);return;}@@ -261,7 +272,20 @@ export default class UpcomingEventsCalendar extends Component {} else {let viewDate;if (view === "week") {- viewDate = moment(viewStart).startOf("isoWeek");+ const viewMiddle = moment(+ (viewStart.valueOf() + viewEnd.valueOf()) / 2+ );+ viewDate = moment(viewMiddle).startOf("isoWeek");+ } else if (view === "day") {+ const viewMiddle = moment(+ (viewStart.valueOf() + viewEnd.valueOf()) / 2+ );+ viewDate = moment(viewMiddle);+ } else if (view === "year") {+ const viewMiddle = moment(+ (viewStart.valueOf() + viewEnd.valueOf()) / 2+ );+ viewDate = moment(viewMiddle);} else {viewDate = moment(viewStart);}diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/helpers/format-event-name.js b/plugins/discourse-calendar/assets/javascripts/discourse/helpers/format-event-name.jsindex b06982bfba2..6075bf0ce55 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/helpers/format-event-name.js+++ b/plugins/discourse-calendar/assets/javascripts/discourse/helpers/format-event-name.js@@ -18,10 +18,7 @@ export function formatEventName(event, userTimezone) {event.timezone &&!sameTimezoneOffset(event.timezone, userTimezone)) {- output +=- ` (${i18n("discourse_calendar.local_time")}: ` +- moment(event.startsAt).tz(event.timezone).format("H:mma") +- ")";+ output += ` (${i18n("discourse_calendar.local_time")})`;}return output;diff --git a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rbindex da9395c2f3f..d794b15c426 100644--- a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb+++ b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb@@ -26,17 +26,18 @@ class RRuleGeneratormax_years: nil,recurrence: "every_week",recurrence_until: nil,- dtstart: nil+ dtstart: nil,+ show_local_time: false)rrule = generate_hash(RRuleConfigurator.rule(recurrence_until:, recurrence:, starts_at:))rrule = set_mandatory_options(rrule, starts_at)rrule_line = "RRULE:#{stringify(rrule)}"if dtstart- if timezone == "UTC"- dtstart_line = "DTSTART:#{dtstart.utc.strftime("%Y%m%dT%H%M%SZ")}"+ if show_local_time+ dtstart_line = "DTSTART:#{dtstart.strftime("%Y%m%dT%H%M%S")}"else- dtstart_line = "DTSTART;TZID=#{timezone}:#{dtstart.strftime("%Y%m%dT%H%M%S")}"+ dtstart_line = "DTSTART:#{dtstart.utc.strftime("%Y%m%dT%H%M%SZ")}"end"#{dtstart_line}\n#{rrule_line}"else@@ -60,9 +61,6 @@ class RRuleGeneratorenddef self.set_mandatory_options(rrule, time)- # Use local time for BYHOUR/BYMINUTE to match the timezone-specific DTSTART- rrule["BYHOUR"] = time.strftime("%H")- rrule["BYMINUTE"] = time.strftime("%M")rrule["INTERVAL"] ||= 1rrule["WKST"] = "MO" # considers Monday as the first day of the weekrrulediff --git a/plugins/discourse-calendar/spec/integration/post_spec.rb b/plugins/discourse-calendar/spec/integration/post_spec.rbindex f7db27856f5..1c03ae07824 100644--- a/plugins/discourse-calendar/spec/integration/post_spec.rb+++ b/plugins/discourse-calendar/spec/integration/post_spec.rb@@ -799,5 +799,29 @@ describe Post doexpect(post.event.original_starts_at).to eq_time(expected_original_datetime)expect(post.event.starts_at).to eq_time(expected_next_datetime)end++ it "handles showLocalTime with non-recurring events" do+ expected_datetime = ActiveSupport::TimeZone["Europe/Prague"].parse("2025-09-07 18:30")++ post =+ PostCreator.create!(+ user,+ title: "Prague dinner",+ raw:+ "[event start='2025-09-07 18:30' end='2025-09-07 21:00' timezone='Europe/Prague' showLocalTime='true']\n[/event]",+ ).reload++ expect(post.event.timezone).to eq("Europe/Prague")+ expect(post.event.show_local_time).to eq(true)+ expect(post.event.original_starts_at).to eq_time(expected_datetime)++ serializer =+ DiscoursePostEvent::BasicEventSerializer.new(post.event, scope: Guardian.new(user))+ serialized = serializer.as_json++ # Should return floating time (no timezone info)+ expect(serialized[:basic_event][:starts_at]).to eq("2025-09-07T18:30:00")+ expect(serialized[:basic_event][:ends_at]).to eq("2025-09-07T21:00:00")+ endendenddiff --git a/plugins/discourse-calendar/spec/lib/discourse_post_event/rrule_generator_spec.rb b/plugins/discourse-calendar/spec/lib/discourse_post_event/rrule_generator_spec.rbindex 6458416e485..5f6efd3f451 100644--- a/plugins/discourse-calendar/spec/lib/discourse_post_event/rrule_generator_spec.rb+++ b/plugins/discourse-calendar/spec/lib/discourse_post_event/rrule_generator_spec.rb@@ -24,12 +24,50 @@ describe RRuleGenerator dofreeze_time DateTime.parse("2020-02-25 15:36")rrule = RRuleGenerator.generate(starts_at: time, timezone:, recurrence: "every_week").first- expect(rrule.to_s).to eq("2020-02-29 15:36:00 +0100")+ expect(rrule.to_s).to eq("2020-02-29 16:36:00 +0100")freeze_time DateTime.parse("2020-09-25 15:36")rrule = RRuleGenerator.generate(starts_at: time, timezone:).first- expect(rrule.to_s).to eq("2020-09-26 15:36:00 +0200")+ expect(rrule.to_s).to eq("2020-09-26 16:36:00 +0200")+ end+ end++ describe "show_local_time" do+ it "generates floating time RRule without timezone when show_local_time is enabled" do+ timezone = "Europe/Prague"+ time = Time.utc(2020, 1, 25, 15, 36)++ rrule_string =+ RRuleGenerator.generate_string(+ starts_at: time,+ timezone: timezone,+ recurrence: "every_week",+ dtstart: time,+ show_local_time: true,+ )++ expect(rrule_string).to eq(+ "DTSTART:20200125T153600\nRRULE:FREQ=WEEKLY;BYDAY=SA;INTERVAL=1;WKST=MO",+ )+ end++ it "generates timezone-specific RRule when show_local_time is disabled" do+ timezone = "Europe/Prague"+ time = Time.utc(2020, 1, 25, 15, 36)++ rrule_string =+ RRuleGenerator.generate_string(+ starts_at: time,+ timezone: timezone,+ recurrence: "every_week",+ dtstart: time,+ show_local_time: false,+ )++ expect(rrule_string).to eq(+ "DTSTART:20200125T153600Z\nRRULE:FREQ=WEEKLY;BYDAY=SA;INTERVAL=1;WKST=MO",+ )endenddiff --git a/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb b/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rbindex 9fd7093211c..18d43df9a14 100644--- a/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb+++ b/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb@@ -517,14 +517,14 @@ describe DiscoursePostEvent::Event doendcontext "when event only has starts_at" do- it "returns nil" do+ it "returns default duration of 1 hour" doevent =DiscoursePostEvent::Event.create!(id: post_1.id,original_starts_at: "2022-01-15 10:00:00 UTC",)- expect(event.duration).to be_nil+ expect(event.duration).to eq("01:00:00")endend@@ -630,13 +630,17 @@ describe DiscoursePostEvent::Event doFabricate(:event,recurrence: "every_day",- recurrence_until: "2020-04-25 06:59",+ recurrence_until: "2020-04-25 23:59",original_starts_at: "2020-04-20 13:00",)end- it "returns nothing" do- expect(next_date).to be_blank+ it "returns the next occurrence within the recurrence period" do+ expect(next_date).not_to be_blank+ expect(next_date).to be_an(Array)+ expect(next_date.length).to eq(2)+ expect(next_date[0]).to eq(Time.utc(2020, 4, 25, 13, 0, 0))+ expect(next_date[1]).to eq(Time.utc(2020, 4, 25, 14, 0, 0))endendend@@ -672,7 +676,7 @@ describe DiscoursePostEvent::Event doroot: false,)json = JSON.parse(serializer.to_json)- # Should not crash and should return nil for starts_at and ends_at+expect(json["starts_at"]).to be_nilexpect(json["ends_at"]).to be_nilend@@ -682,13 +686,8 @@ describe DiscoursePostEvent::Event doDiscoursePostEvent::BasicEventSerializer.new(expired_recurring_event, root: false)json = JSON.parse(serializer.to_json)- expected_starts_at =- expired_recurring_event.original_starts_at.in_time_zone(expired_recurring_event.timezone)- expected_ends_at =- expired_recurring_event.original_ends_at.in_time_zone(expired_recurring_event.timezone)-- expect(json["starts_at"]).to eq(expected_starts_at.iso8601(3))- expect(json["ends_at"]).to eq(expected_ends_at.iso8601(3))+ expect(json["starts_at"]).to be_nil+ expect(json["ends_at"]).to be_nilendenddiff --git a/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb b/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rbindex 476089008e8..200dfa2395e 100644--- a/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb+++ b/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb@@ -77,9 +77,10 @@ describe DiscoursePostEvent::EventSerializer do)end- it "does not include duration in serialized output" do+ it "includes default 1-hour duration in serialized output" dojson = DiscoursePostEvent::EventSerializer.new(event_no_end, scope: Guardian.new).as_json- expect(json[:event]).not_to have_key(:duration)+ expect(json[:event]).to have_key(:duration)+ expect(json[:event][:duration]).to eq("01:00:00")endendenddiff --git a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/upcoming_events.rb b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/upcoming_events.rbindex 74bff98840c..c5e88013afd 100644--- a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/upcoming_events.rb+++ b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/upcoming_events.rb@@ -22,18 +22,26 @@ module PageObjectsdef open_year_viewfind(".fc-listYear-button").click+ expect(page).to have_css(".fc-listYear-view")+ wait_for_timeoutenddef open_day_viewfind(".fc-timeGridDay-button").click+ expect(page).to have_css(".fc-timeGridDay-view")+ wait_for_timeoutenddef open_week_viewfind(".fc-timeGridWeek-button").click+ expect(page).to have_css(".fc-timeGridWeek-view")+ wait_for_timeoutenddef open_month_viewfind(".fc-dayGridMonth-button").click+ expect(page).to have_css(".fc-dayGridMonth-view")+ wait_for_timeoutenddef open_mine_events@@ -120,6 +128,11 @@ module PageObjectsfind(".fc-event", text: title)end+ def has_event_with_time?(title, time)+ event = find_event_by_title(title)+ event.has_css?(".fc-list-event-time", text: time)+ end+def get_event_height(title)find_event_by_title(title).native.bounding_box["height"]enddiff --git a/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb b/plugins/discourse-calendar/spec/system/upcoming_events_spec.rbindex 511d441034a..a382ef1a58c 100644--- a/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb+++ b/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb@@ -26,51 +26,214 @@ describe "Upcoming Events", type: :system doenddescribe "event display and formatting" do- describe "local time display" do- before do- admin.user_option.update!(timezone: "America/New_York")+ before { admin.user_option.update!(timezone: "America/New_York") }++ describe "non-recurring events" do+ describe "with local time enabled" do+ it "displays event time in event timezone with (Local time) suffix",+ timezone: "Australia/Brisbane",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Local time event",+ raw:+ "[event showLocalTime=true timezone=CET start=\"2025-09-11 08:05\" end=\"2025-09-11 10:05\"]\n[/event]",+ )++ upcoming_events.visit+ upcoming_events.open_year_view++ expect(upcoming_events).to have_event_with_time(+ "Local time event (Local time)",+ "8:05am - 10:05am",+ )++ find("a", text: "Local time event (Local time)").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Thu, Sep 11 8:05 AM (CET) → 10:05 AM (CET)",+ )+ end+ end- PostCreator.create!(- admin,- title: "Event with local time",- raw: "[event showLocalTime=true timezone=CET start=\"2025-09-11 08:05\"]\n[/event]",- )+ describe "without local time (UTC events)" do+ it "displays event time converted to user timezone",+ timezone: "Australia/Brisbane",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Event with UTC time",+ raw:+ "[event timezone=CET start=\"2025-09-11 19:00\" end=\"2025-09-11 21:00\"]\n[/event]",+ )- PostCreator.create!(- admin,- title: "Event without local time",- raw: "[event timezone=CET start=\"2025-09-11 19:00\"]\n[/event]",- )+ upcoming_events.visit+ upcoming_events.open_year_view- PostCreator.create!(- admin,- title: "Event with local time and same timezone than user",- raw:- "[event showLocalTime=true timezone=\"America/New_York\" start=\"2025-09-12 08:05\"]\n[/event]",- )+ expect(upcoming_events).to have_event_with_time("Event with UTC time", "1:00pm - 3:00pm")++ find("a", text: "Event with UTC time").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Tomorrow 1:00 PM → 3:00 PM",+ )+ endend- it "shows local time when showLocalTime is enabled",- timezone: "Australia/Brisbane",- time: Time.utc(2025, 6, 2, 19, 00) do- upcoming_events.visit- upcoming_events.open_year_view+ describe "with same timezone as user" do+ it "displays event time normally when event timezone matches user timezone",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Same timezone event",+ raw:+ "[event showLocalTime=true timezone=\"America/New_York\" start=\"2025-09-12 08:05\" end=\"2025-09-12 09:05\"]\n[/event]",+ )- first_item = upcoming_events.find_event_by_position(2)- expect(upcoming_events.event_time_text(first_item)).to include("2:05am")- expect(upcoming_events.event_title_text(first_item)).to eq(- "Event with local time (Local time: 8:05am)",- )+ upcoming_events.visit+ upcoming_events.open_year_view- second_item = upcoming_events.find_event_by_position(3)- expect(upcoming_events.event_time_text(second_item)).to include("1:00pm")- expect(upcoming_events.event_title_text(second_item)).to eq("Event without local time")+ expect(upcoming_events).to have_event_with_time("Same timezone event", "8:05am - 9:05am")- third_item = upcoming_events.find_event_by_position(5)- expect(upcoming_events.event_time_text(third_item)).to include("8:05am")- expect(upcoming_events.event_title_text(third_item)).to eq(- "Event with local time and same timezone than user",- )+ find("a", text: "Same timezone event").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Fri, Sep 12 8:05 AM → 9:05 AM",+ )+ end+ end+ end++ describe "recurring events" do+ describe "with local time enabled" do+ it "displays multiple occurrences with correct local time",+ timezone: "Australia/Brisbane",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Recurring local event",+ raw:+ "[event recurrence=every_week showLocalTime=true timezone=CET start=\"2025-09-11 08:05\" end=\"2025-09-11 10:05\"]\n[/event]",+ )++ upcoming_events.visit+ upcoming_events.open_year_view++ expect(page).to have_css(+ "tr.fc-list-event:nth-child(2) .fc-list-event-time",+ text: "8:05am - 10:05am",+ )+ expect(page).to have_css(+ "tr.fc-list-event:nth-child(4) .fc-list-event-time",+ text: "8:05am - 10:05am",+ )++ find("tr.fc-list-event:nth-child(2) .fc-list-event-title a").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Thu, Sep 11 8:05 AM (CET) → 10:05 AM (CET)",+ )++ page.send_keys(:escape)++ find("tr.fc-list-event:nth-child(4) .fc-list-event-title a").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Thu, Sep 18 8:05 AM (CET) → 10:05 AM (CET)",+ )+ end+ end++ describe "without local time (UTC events)" do+ it "displays multiple occurrences converted to user timezone",+ timezone: "Australia/Brisbane",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Recurring UTC event",+ raw:+ "[event recurrence=every_week timezone=CET start=\"2025-09-11 19:00\" end=\"2025-09-11 20:00\"]\n[/event]",+ )+ upcoming_events.visit+ upcoming_events.open_year_view++ expect(page).to have_css(+ "tr.fc-list-event:nth-child(2) .fc-list-event-time",+ text: "1:00pm - 2:00pm",+ )+ expect(page).to have_css(+ "tr.fc-list-event:nth-child(4) .fc-list-event-time",+ text: "1:00pm - 2:00pm",+ )++ find(+ "tr.fc-list-event:nth-child(2) .fc-list-event-title a",+ text: "Recurring UTC event",+ ).click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Tomorrow 1:00 PM → 2:00 PM (New York)",+ )++ page.send_keys(:escape)++ find(+ "tr.fc-list-event:nth-child(4) .fc-list-event-title a",+ text: "Recurring UTC event",+ ).click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Thu, Sep 18 1:00 PM → 2:00 PM",+ )+ end+ end++ describe "with same timezone as user" do+ it "displays multiple occurrences without timezone conversion issues",+ timezone: "Australia/Brisbane",+ time: Time.utc(2025, 9, 10, 12, 0) do+ PostCreator.create!(+ admin,+ title: "Recurring same TZ event",+ raw:+ "[event recurrence=every_week showLocalTime=true timezone=\"America/New_York\" start=\"2025-09-12 08:05\" end=\"2025-09-12 10:05\"]\n[/event]",+ )++ upcoming_events.visit+ upcoming_events.open_year_view++ expect(page).to have_css(+ "tr.fc-list-event:nth-child(2) .fc-list-event-time",+ text: "8:05am - 10:05am",+ )+ expect(page).to have_css(+ "tr.fc-list-event:nth-child(4) .fc-list-event-time",+ text: "8:05am - 10:05am",+ )++ find("tr.fc-list-event:nth-child(2) .fc-list-event-title a").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Fri, Sep 12 8:05 AM → 10:05 AM (New York)",+ )++ page.send_keys(:escape)++ find("tr.fc-list-event:nth-child(4) .fc-list-event-title a").click++ expect(page).to have_css(+ ".event__section.event-dates",+ text: "Fri, Sep 19 8:05 AM → 10:05 AM",+ )+ endendenddiff --git a/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs b/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjsindex f3959f7e96e..18361d3633d 100644--- a/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs+++ b/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs@@ -25,18 +25,18 @@ module("Integration | Component | Dates", function (hooks) {starts,today: {...starts,- startsAt: "2025-11-01T14:00:00Z",- endsAt: "2025-11-01T16:00:00Z",+ startsAt: "2025-11-01T08:00:00Z",+ endsAt: "2025-11-01T09:00:00Z",},yesterdayTomorrow: {...starts,startsAt: "2025-10-31T08:00:00Z",- endsAt: "2025-11-02T18:00:00Z",+ endsAt: "2025-11-02T08:00:00Z",},weekdays: {...starts,- startsAt: "2025-10-31T00:00:00Z",- endsAt: "2025-11-03T00:00:00Z",+ startsAt: "2025-11-01T14:00:00Z",+ endsAt: "2025-11-02T14:00:00Z",},endsSameDay: {...starts,@@ -74,7 +74,7 @@ module("Integration | Component | Dates", function (hooks) {assert.dom(".event-dates").hasText(- "Friday → Monday",+ "Sunday → Monday","`startsAt` should show full weekday names");});@@ -164,7 +164,7 @@ module("Integration | Component | Dates", function (hooks) {assert.dom(".event-dates").hasText(- "Yesterday 8:00 AM → Tomorrow 6:00 PM",+ "Yesterday 6:00 PM → Tomorrow 6:00 PM","`startsAt` should not show current year and time");});@@ -181,7 +181,7 @@ module("Integration | Component | Dates", function (hooks) {assert.dom(".event-dates").hasText(- "Today 2:00 PM → 4:00 PM (UTC)",+ "Today 6:00 PM → 7:00 PM (Brisbane)","`endsAt` should show from today time to time only");});diff --git a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.jsindex 4689e422f4e..1aa60645049 100644--- a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js+++ b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js@@ -16,12 +16,12 @@ import LocalDateBuilder from "../lib/local-date-builder";import richEditorExtension from "../lib/rich-editor-extension";// Import applyLocalDates from discourse/lib/local-dates instead-export function applyLocalDates(dates, siteSettings) {+export function applyLocalDates(dates, siteSettings, timezone) {if (!siteSettings.discourse_local_dates_enabled) {return;}- const currentUserTZ = moment.tz.guess();+ const currentUserTZ = timezone || moment.tz.guess();dates.forEach((element, index, arr) => {const opts = buildOptionsFromElement(element, siteSettings);