Skip to content

A platform for community discussion. Free, open, simple.

FIX: maintain wall clock time between DST transitions (#35833)

Joffrey JAFFEUXfdfc603f6e70
diff --git a/frontend/discourse/app/lib/load-rrule.js b/frontend/discourse/app/lib/load-rrule.js
deleted file mode 100644
index e5fbef0a0bf..00000000000
--- a/frontend/discourse/app/lib/load-rrule.js
+++ /dev/null
@@ -1,7 +0,0 @@
-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/frontend/discourse/app/static/full-calendar-bundle.js b/frontend/discourse/app/static/full-calendar-bundle.js
index 56fce6bf0c4..0cb9ca5e599 100644
--- a/frontend/discourse/app/static/full-calendar-bundle.js
+++ b/frontend/discourse/app/static/full-calendar-bundle.js
@@ -2,5 +2,5 @@ export { Calendar } from "@fullcalendar/core";
export { default as DayGrid } from "@fullcalendar/daygrid";
export { default as TimeGrid } from "@fullcalendar/timegrid";
export { default as List } from "@fullcalendar/list";
-export { default as RRULE } from "@fullcalendar/rrule";
-export { default as MomentTimezone } from "@fullcalendar/moment-timezone";
+export { default as MomentPlugin } from "@fullcalendar/moment";
+export { default as MomentTimezonePlugin } from "@fullcalendar/moment-timezone";
diff --git a/frontend/discourse/app/static/rrule-bundle.js b/frontend/discourse/app/static/rrule-bundle.js
deleted file mode 100644
index ad9649a4eac..00000000000
--- a/frontend/discourse/app/static/rrule-bundle.js
+++ /dev/null
@@ -1 +0,0 @@
-export { rrulestr } from "rrule";
diff --git a/frontend/discourse/package.json b/frontend/discourse/package.json
index 8ab1adc1845..e2319ebeeee 100644
--- a/frontend/discourse/package.json
+++ b/frontend/discourse/package.json
@@ -28,8 +28,8 @@
"@fullcalendar/core": "^6.1.19",
"@fullcalendar/daygrid": "^6.1.19",
"@fullcalendar/list": "^6.1.19",
+ "@fullcalendar/moment": "^6.1.19",
"@fullcalendar/moment-timezone": "^6.1.19",
- "@fullcalendar/rrule": "^6.1.18",
"@fullcalendar/timegrid": "^6.1.19",
"@glimmer/syntax": "0.93.1",
"@glimmer/tracking": "^1.1.2",
@@ -154,13 +154,13 @@
"source-map": "^0.7.6",
"terser": "^5.44.1",
"testem": "^3.16.0",
+ "typescript": "^5.9.3",
"util": "^0.12.5",
"virtual-dom": "^2.1.1",
"webpack": "5.99.9",
"webpack-retry-chunk-load-plugin": "^3.1.1",
"webpack-stats-plugin": "^1.1.3",
- "xss": "^1.0.15",
- "typescript": "^5.9.3"
+ "xss": "^1.0.15"
},
"engines": {
"node": ">= 18",
diff --git a/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb b/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb
index 5ec5dc45aac..5ec35f85f9a 100644
--- a/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb
+++ b/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb
@@ -13,9 +13,6 @@ module DiscoursePostEvent
},
)
- # The detailed serializer is currently not used anywhere in the frontend, but available via API
- serializer = params[:include_details] == "true" ? EventSerializer : BasicEventSerializer
-
respond_to do |format|
format.ics do
filename = "events-#{Digest::SHA1.hexdigest(@events.map(&:id).sort.join("-"))}.ics"
@@ -23,12 +20,37 @@ module DiscoursePostEvent
end
format.json do
- render json:
- ActiveModel::ArraySerializer.new(
- @events,
- each_serializer: serializer,
- scope: guardian,
- ).as_json
+ # The detailed serializer is currently not used anywhere in the frontend, but available via API
+ serializer = params[:include_details] == "true" ? EventSerializer : BasicEventSerializer
+
+ serialized_events =
+ @events.map do |event|
+ expanded =
+ DiscoursePostEvent::Action::ExpandOccurrences.call(
+ event: event,
+ after: filtered_events_params[:after]&.to_datetime || Time.current,
+ before: filtered_events_params[:before]&.to_datetime,
+ limit: filtered_events_params[:limit]&.to_i || 50,
+ )
+
+ formatted_occurrences =
+ expanded[:occurrences].map do |occurrence|
+ {
+ starts_at: format_time(event, occurrence[:starts_at]),
+ ends_at: format_time(event, occurrence[:ends_at]),
+ }
+ end
+
+ serializer.new(
+ event,
+ scope: guardian,
+ root: false,
+ occurrences: formatted_occurrences,
+ include_occurrences: true,
+ ).as_json
+ end
+
+ render json: { events: serialized_events }
end
end
end
@@ -47,6 +69,7 @@ module DiscoursePostEvent
def show
event = Event.find(params[:id])
guardian.ensure_can_see!(event.post)
+
serializer = EventSerializer.new(event, scope: guardian)
render_json_dump(serializer)
end
@@ -145,5 +168,15 @@ module DiscoursePostEvent
:order,
)
end
+
+ def format_time(event, time)
+ return nil unless time
+
+ if event.show_local_time
+ time.in_time_zone(event.timezone).strftime("%Y-%m-%dT%H:%M:%S")
+ else
+ time.in_time_zone(event.timezone).iso8601(3)
+ end
+ end
end
end
diff --git a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb b/plugins/discourse-calendar/app/models/discourse_post_event/event.rb
index b1e6557cbeb..c411b7fc41a 100644
--- a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb
+++ b/plugins/discourse-calendar/app/models/discourse_post_event/event.rb
@@ -433,6 +433,20 @@ module DiscoursePostEvent
[next_starts_at, next_ends_at]
end
+ def calculate_next_occurrence_from(from_time)
+ return nil if recurrence.blank?
+ if original_starts_at > from_time
+ return { starts_at: original_starts_at, ends_at: original_ends_at }
+ end
+
+ next_starts_at = calculate_next_recurring_date_from(from_time)
+ return nil unless next_starts_at
+
+ event_duration = original_ends_at ? original_ends_at - original_starts_at : 3600
+ next_ends_at = next_starts_at + event_duration
+ { starts_at: next_starts_at, ends_at: next_ends_at }
+ end
+
def duration
return nil unless original_starts_at
@@ -502,6 +516,25 @@ module DiscoursePostEvent
dtstart: timezone_starts_at,
).first
end
+
+ def calculate_next_recurring_date_from(from_time)
+ timezone_starts_at = original_starts_at.in_time_zone(timezone)
+ timezone_recurrence_until = recurrence_until&.in_time_zone(timezone)
+ from_time_in_tz = from_time.in_time_zone(timezone)
+
+ RRule::Rule
+ .new(
+ RRuleConfigurator.rule(
+ recurrence_until: timezone_recurrence_until,
+ recurrence: recurrence,
+ starts_at: timezone_starts_at,
+ ),
+ dtstart: timezone_starts_at,
+ tzid: rrule_timezone,
+ )
+ .between(from_time_in_tz - 1.hour, from_time_in_tz + 1.year)
+ .find { |date| date >= from_time_in_tz }
+ end
end
end
diff --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.rb
index 22d60196a51..1af4f1d5673 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
@@ -13,7 +13,8 @@ module DiscoursePostEvent
:show_local_time,
:timezone,
:post,
- :duration
+ :duration,
+ :occurrences
def category_id
object.post.topic.category_id
@@ -53,7 +54,6 @@ module DiscoursePostEvent
RRuleGenerator.generate_string(
starts_at: timezone_starts_at,
- timezone: object.rrule_timezone,
recurrence: object.recurrence,
recurrence_until: timezone_recurrence_until,
dtstart: timezone_starts_at,
@@ -71,13 +71,8 @@ module DiscoursePostEvent
timezone_time = object.original_starts_at&.in_time_zone(object.timezone)
timezone_time&.strftime("%Y-%m-%dT%H:%M:%S")
else
- 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)
- end
+ timezone_time = object.starts_at&.in_time_zone(object.timezone)
+ timezone_time&.iso8601(3)
end
end
@@ -94,23 +89,15 @@ module DiscoursePostEvent
timezone_ends_at = ends_at&.in_time_zone(object.timezone)
timezone_ends_at&.strftime("%Y-%m-%dT%H:%M:%S")
else
- 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)
+ if object.ends_at
+ timezone_ends_at = object.ends_at&.in_time_zone(object.timezone)
timezone_ends_at&.iso8601(3)
else
- if object.ends_at
- timezone_ends_at = object.ends_at&.in_time_zone(object.timezone)
- timezone_ends_at&.iso8601(3)
+ base_starts_at = object.starts_at&.in_time_zone(object.timezone)
+ if base_starts_at
+ (base_starts_at + 1.hour).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
+ nil
end
end
end
@@ -123,5 +110,13 @@ module DiscoursePostEvent
def include_duration?
object.duration.present?
end
+
+ def occurrences
+ @options[:occurrences]
+ end
+
+ def include_occurrences?
+ @options[:include_occurrences] != false
+ end
end
end
diff --git a/plugins/discourse-calendar/app/services/discourse_post_event/action/expand_occurrences.rb b/plugins/discourse-calendar/app/services/discourse_post_event/action/expand_occurrences.rb
new file mode 100644
index 00000000000..cbf722d7bdc
--- /dev/null
+++ b/plugins/discourse-calendar/app/services/discourse_post_event/action/expand_occurrences.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+module DiscoursePostEvent
+ module Action
+ class ExpandOccurrences < Service::ActionBase
+ option :event
+ option :after
+ option :before, optional: true
+ option :limit, default: -> { 50 }
+
+ def call
+ return non_recurring_result unless event.recurring?
+
+ build_recurring_occurrences
+ end
+
+ private
+
+ def non_recurring_result
+ {
+ event: event,
+ occurrences: [{ starts_at: event.original_starts_at, ends_at: event.original_ends_at }],
+ }
+ end
+
+ def build_recurring_occurrences
+ occurrences = []
+ current_time = after
+ count = 0
+
+ while count < limit
+ occurrence = event.calculate_next_occurrence_from(current_time)
+ break unless occurrence
+
+ occurrence_starts_at = occurrence[:starts_at]
+ break if before && occurrence_starts_at >= before
+
+ occurrences << { starts_at: occurrence_starts_at, ends_at: occurrence[:ends_at] }
+ current_time = occurrence_starts_at + 1.second
+ count += 1
+ end
+
+ { event: event, occurrences: occurrences }
+ end
+ end
+ end
+end
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
index 038bf2ed6ba..fc06ede00ea 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/category-calendar.gjs
@@ -136,9 +136,7 @@ export default class CategoryCalendar extends Component {
return {
title: formatEventName(event, this.currentUser?.user_option?.timezone),
start: startsAt,
- rrule: event.rrule,
end: endsAt || startsAt,
- duration: event.duration,
allDay: !isNotFullDayEvent(moment(startsAt), moment(endsAt)),
url: getURL(`/t/-/${post.topic.id}/${post.post_number}`),
backgroundColor,
diff --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.gjs
index c4fd68568a2..f49760be5ca 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
@@ -7,7 +7,6 @@ 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";
@@ -21,21 +20,17 @@ export default class DiscoursePostEventDates extends Component {
return this.args.event.timezone || "UTC";
}
+ get showLocalTime() {
+ return this.args.event.showLocalTime ?? true;
+ }
+
get startsAt() {
- return (
- this.args.currentEventStart ??
- moment(this.args.event.startsAt).tz(this.timezone)
- );
+ return moment.tz(this.args.event.startsAt, this.timezone);
}
get endsAt() {
- const currentEventEnd = this.args.currentEventEnd;
const eventEndsAt = this.args.event.endsAt;
-
- return (
- currentEventEnd ??
- (eventEndsAt ? moment(eventEndsAt).tz(this.timezone) : null)
- );
+ return eventEndsAt ? moment.tz(eventEndsAt, this.timezone) : null;
}
get startsAtFormat() {
@@ -134,8 +129,6 @@ export default class DiscoursePostEventDates extends Component {
return;
}
- this.rrule = await loadRRule();
-
if (this.siteSettings.discourse_local_dates_enabled) {
const bbcode = this.datesBBCode.join("<span> → </span>");
const result = await cook(bbcode);
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.gjs
index a70f5ddef6f..b999f161858 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,6 +1,5 @@
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";
@@ -12,7 +11,6 @@ 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";
@@ -43,8 +41,7 @@ export default class DiscoursePostEvent extends Component {
@service discoursePostEventApi;
@service messageBus;
- @tracked event = this.args.event;
- @tracked rrule;
+ @tracked event;
setupMessageBus = modifier(() => {
const path = `/discourse-post-event/${this.event.post.topic.id}`;
@@ -56,82 +53,14 @@ export default class DiscoursePostEvent extends Component {
return () => this.messageBus.unsubscribe(path);
});
- 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 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;
+ getDisplayTime(time) {
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");
- }
+ return moment.tz(time, this.event.timezone || "UTC");
} else {
- result = moment
- .utc(start)
+ return moment
+ .utc(time)
.tz(this.currentUser?.user_option?.timezone || moment.tz.guess());
}
-
- return result;
}
get withDescription() {
@@ -139,11 +68,13 @@ export default class DiscoursePostEvent extends Component {
}
get startsAtMonth() {
- return this.currentEventStart.format("MMM");
+ const displayTime = this.getDisplayTime(this.event.startsAt);
+ return displayTime.format("MMM");
}
get startsAtDay() {
- return this.currentEventStart.format("D");
+ const displayTime = this.getDisplayTime(this.event.startsAt);
+ return displayTime.format("D");
}
get eventName() {
@@ -170,22 +101,17 @@ export default class DiscoursePostEvent extends Component {
return this.event.isExpired && this.event.recurrence;
}
- @action
- async loadRRule() {
- this.rrule = await loadRRule();
- }
-
@bind
async loadEvent() {
if (this.event) {
return this.event;
}
- if (this.args.eventId) {
+ if (this.args.event) {
try {
- return (this.event = await this.discoursePostEventApi.event(
- this.args.eventId
- ));
+ this.event = await this.discoursePostEventApi.event(this.args.event.id);
+ this.event.startsAt = this.args.event.startsAt;
+ this.event.endsAt = this.args.event.endsAt;
} catch (error) {
popupAjaxError(error);
}
@@ -195,117 +121,109 @@ export default class DiscoursePostEvent extends Component {
<template>
<AsyncContent @asyncData={{this.loadEvent}}>
<:content as |event|>
- {{#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 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="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 class="day">
+ {{#if this.expiredAndRecurring}}
+ -
+ {{else}}
+ {{this.startsAtDay}}
+ {{/if}}
</div>
-
- <MoreMenu
- @event={{event}}
- @isStandaloneEvent={{this.isStandaloneEvent}}
- @composePrivateMessage={{routeAction
- "composePrivateMessage"
- }}
+ </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>
+ </div>
+
+ <MoreMenu
+ @event={{event}}
+ @isStandaloneEvent={{this.isStandaloneEvent}}
+ @composePrivateMessage={{routeAction "composePrivateMessage"}}
+ />
+
+ {{#if @onClose}}
+ <DButton
+ class="btn-default btn-small discourse-post-event-close"
+ @icon="xmark"
+ @action={{@onClose}}
/>
-
- {{#if @onClose}}
- <DButton
- class="btn-default btn-small discourse-post-event-close"
- @icon="xmark"
- @action={{@onClose}}
- />
- {{/if}}
- </header>
-
- <PluginOutlet
- @name="discourse-post-event-info"
- @outletArgs={{lazyHash
+ {{/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
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
- 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>
+ 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}}
</div>
- {{/if}}
+ </div>
</:content>
<:loading>
<div class="discourse-post-event-loader">
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs
index e05332743c0..82ba0b4b4ff 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs
@@ -83,7 +83,6 @@ export default class DiscoursePostEventMoreMenu extends Component {
},
],
{
- rrule: event.rrule,
location: event.location,
details: event.description,
}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
index 426a2012071..79940a66ba2 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/full-calendar.gjs
@@ -19,10 +19,8 @@ const PostEventMenu = <template>
<DiscoursePostEvent
@linkToPost={{true}}
@event={{@data.event}}
- @eventId={{@data.eventId}}
@onClose={{@data.onClose}}
@withDescription={{false}}
- @currentEventStart={{@data.currentEventStart}}
/>
</template>;
@@ -100,8 +98,8 @@ export default class FullCalendar extends Component {
calendarModule.DayGrid,
calendarModule.TimeGrid,
calendarModule.List,
- calendarModule.RRULE,
- calendarModule.MomentTimezone,
+ calendarModule.MomentPlugin,
+ calendarModule.MomentTimezonePlugin,
],
initialView: this.initialView,
headerToolbar: this.headerToolbar,
@@ -148,8 +146,7 @@ export default class FullCalendar extends Component {
modalForMobile: true,
maxWidth: 500,
data: {
- currentEventStart: event.start,
- eventId: postEvent.id,
+ event: postEvent,
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.gjs
index e9b1ae11f2e..8e36ad9609f 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
@@ -64,7 +64,7 @@ export default class UpcomingEventsCalendar extends Component {
let backgroundColor;
- if (post.topic.tags) {
+ if (post?.topic?.tags) {
const tagColorEntry = tagsColorsMap.find(
(entry) =>
entry.type === "tag" && post.topic.tags.includes(entry.slug)
@@ -75,7 +75,7 @@ export default class UpcomingEventsCalendar extends Component {
if (!backgroundColor) {
const categoryColorEntry = tagsColorsMap.find(
(entry) =>
- entry.type === "category" && entry.slug === post.category_slug
+ entry.type === "category" && entry.slug === post?.category_slug
);
backgroundColor = categoryColorEntry?.color;
}
@@ -88,12 +88,10 @@ export default class UpcomingEventsCalendar extends Component {
return {
extendedProps: { postEvent: event },
title: formatEventName(event, this.currentUser?.user_option?.timezone),
- rrule: event.rrule,
start: startsAt,
end: endsAt || startsAt,
- duration: event.duration,
allDay: !isNotFullDayEvent(moment(startsAt), moment(endsAt)),
- url: getURL(`/t/-/${post.topic.id}/${post.post_number}`),
+ url: getURL(`/t/-/${post?.topic?.id}/${post?.post_number}`),
backgroundColor,
};
});
@@ -137,7 +135,7 @@ export default class UpcomingEventsCalendar extends Component {
const localDate = moment(info.view.currentStart)
.clone()
- .tz(this.currentUser?.user_option?.timezone);
+ .tz(this.currentUser?.user_option?.timezone ?? moment.tz.guess());
this.router.replaceWith(
this.router.currentRouteName,
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-api.js b/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-api.js
index 8dfeceecbca..8a0b874f728 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-api.js
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-api.js
@@ -13,8 +13,8 @@ import DiscoursePostEventInvitees from "discourse/plugins/discourse-calendar/dis
export default class DiscoursePostEventApi extends Service {
eventsPromise = null;
- async event(id) {
- const result = await this.#getRequest(`/events/${id}`);
+ async event(id, data = {}) {
+ const result = await this.#getRequest(`/events/${id}`, data);
return DiscoursePostEventEvent.create(result.event);
}
@@ -23,9 +23,20 @@ export default class DiscoursePostEventApi extends Service {
this.eventsPromise.abort();
}
this.eventsPromise = this.#getRequest("/events", data);
- const result = await this.eventsPromise;
+ const response = await this.eventsPromise;
this.eventsPromise = null;
- return result.events.map((e) => DiscoursePostEventEvent.create(e));
+
+ return (response.events || []).flatMap((eventData) => {
+ const occurrences = eventData.occurrences || [];
+
+ return occurrences.map((occurrence) => {
+ return DiscoursePostEventEvent.create({
+ ...eventData,
+ starts_at: occurrence.starts_at,
+ ends_at: occurrence.ends_at,
+ });
+ });
+ });
}
async listEventInvitees(event, data = {}) {
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-service.js b/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-service.js
index ffbec515567..e18febe59e5 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-service.js
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/services/discourse-post-event-service.js
@@ -4,7 +4,6 @@ export default class DiscoursePostEventService extends Service {
@service discoursePostEventApi;
async fetchEvents(params = {}) {
- const events = await this.discoursePostEventApi.events(params);
- return await events;
+ return await this.discoursePostEventApi.events(params);
}
}
diff --git a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb
index b9015a54e14..a26a333a92b 100644
--- a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb
+++ b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb
@@ -22,8 +22,6 @@ class RRuleGenerator
def self.generate_string(
starts_at:,
- timezone: "UTC",
- max_years: nil,
recurrence: "every_week",
recurrence_until: nil,
dtstart: nil,
diff --git a/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb b/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
index e882488d49a..650ef6561f2 100644
--- a/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
+++ b/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
@@ -473,5 +473,38 @@ describe Jobs::DiscoursePostEventSendReminder do
}
end
end
+
+ context "with DST transitions" do
+ fab!(:dst_user, :user)
+
+ it "maintains wall-clock time for events and reminders across DST transitions" do
+ start_time = Time.find_zone("America/New_York").parse("2025-10-29 11:00")
+
+ dst_event =
+ Fabricate(
+ :event,
+ post: Fabricate(:post),
+ reminders: "notification.5.minutes",
+ original_starts_at: start_time,
+ original_ends_at: start_time + 1.hour,
+ timezone: "America/New_York",
+ recurrence: "every_week",
+ )
+
+ DiscoursePostEvent::Invitee.create_attendance!(dst_user.id, dst_event.id, :going)
+
+ freeze_time(Time.find_zone("America/New_York").parse("2025-11-05 10:50"))
+
+ dst_event.set_next_date
+ monitor_job = Jobs::DiscourseCalendar::MonitorEventDates.new
+ monitor_job.execute({})
+
+ expect(dst_user.reload.unread_notifications).to eq(0)
+
+ freeze_time(Time.find_zone("America/New_York").parse("2025-11-05 10:55"))
+
+ expect { monitor_job.execute({}) }.to change { dst_user.reload.unread_notifications }.by(1)
+ end
+ end
end
end
diff --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.rb
index 5f6efd3f451..9718899135b 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
@@ -35,13 +35,11 @@ describe RRuleGenerator do
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,
@@ -53,13 +51,11 @@ describe RRuleGenerator do
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,
diff --git a/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_detailed_response.json b/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_detailed_response.json
index aea7c58b203..fd1d334cfb9 100644
--- a/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_detailed_response.json
+++ b/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_detailed_response.json
@@ -12,24 +12,42 @@
"type": "integer"
},
"category_id": {
- "type": ["integer", "null"]
+ "type": [
+ "integer",
+ "null"
+ ]
},
"name": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"recurrence": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"recurrence_until": {
- "type": ["string", "null"],
+ "type": [
+ "string",
+ "null"
+ ],
"format": "date-time"
},
"starts_at": {
- "type": ["string", "null"],
+ "type": [
+ "string",
+ "null"
+ ],
"format": "date-time"
},
"ends_at": {
- "type": ["string", "null"],
+ "type": [
+ "string",
+ "null"
+ ],
"format": "date-time"
},
"rrule": {
@@ -39,17 +57,26 @@
"type": "boolean"
},
"timezone": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"duration": {
"type": "string",
"pattern": "^\\d{2}:\\d{2}:\\d{2}$"
},
"can_act_on_discourse_post_event": {
- "type": ["boolean", "null"]
+ "type": [
+ "boolean",
+ "null"
+ ]
},
"can_update_attendance": {
- "type": ["boolean", "null"]
+ "type": [
+ "boolean",
+ "null"
+ ]
},
"creator": {
"type": "object",
@@ -62,16 +89,26 @@
"type": "string"
},
"name": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"avatar_template": {
"type": "string"
}
},
- "required": ["id", "username", "avatar_template"]
+ "required": [
+ "id",
+ "username",
+ "avatar_template"
+ ]
},
"custom_fields": {
- "type": ["object", "null"]
+ "type": [
+ "object",
+ "null"
+ ]
},
"is_closed": {
"type": "boolean"
@@ -92,10 +129,16 @@
"type": "boolean"
},
"minimal": {
- "type": ["boolean", "null"]
+ "type": [
+ "boolean",
+ "null"
+ ]
},
"raw_invitees": {
- "type": ["array", "null"],
+ "type": [
+ "array",
+ "null"
+ ],
"items": {
"type": "string"
}
@@ -113,13 +156,21 @@
},
"period": {
"type": "string",
- "enum": ["before", "after"]
+ "enum": [
+ "before",
+ "after"
+ ]
},
"type": {
"type": "string"
}
},
- "required": ["value", "unit", "period", "type"]
+ "required": [
+ "value",
+ "unit",
+ "period",
+ "type"
+ ]
}
},
"sample_invitees": {
@@ -136,28 +187,47 @@
},
"status": {
"type": "string",
- "enum": ["public", "private", "standalone"]
+ "enum": [
+ "public",
+ "private",
+ "standalone"
+ ]
},
"url": {
"type": "string"
},
"description": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"location": {
- "type": ["string", "null"]
+ "type": [
+ "string",
+ "null"
+ ]
},
"watching_invitee": {
- "type": ["object", "null"]
+ "type": [
+ "object",
+ "null"
+ ]
},
"chat_enabled": {
- "type": ["boolean", "null"]
+ "type": [
+ "boolean",
+ "null"
+ ]
},
"channel": {
"type": "object"
},
"max_attendees": {
- "type": ["integer", "null"]
+ "type": [
+ "integer",
+ "null"
+ ]
},
"at_capacity": {
"type": "boolean"
@@ -198,10 +268,46 @@
"type": "object"
}
},
- "required": ["id", "title", "tags", "tags_descriptions"]
+ "required": [
+ "id",
+ "title",
+ "tags",
+ "tags_descriptions"
+ ]
}
},
- "required": ["id", "post_number", "url", "category_slug", "topic"]
+ "required": [
+ "id",
+ "post_number",
+ "url",
+ "category_slug",
+ "topic"
+ ]
+ },
+ "occurrences": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "starts_at": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "ends_at": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "starts_at",
+ "ends_at"
+ ]
+ }
}
},
"required": [
@@ -222,10 +328,13 @@
"should_display_invitees",
"status",
"at_capacity",
- "post"
+ "post",
+ "occurrences"
]
}
}
},
- "required": ["events"]
-}
+ "required": [
+ "events"
+ ]
+}
\ No newline at end of file
diff --git a/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_response.json b/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_response.json
index 72ffadb349c..5bdd22316a3 100644
--- a/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_response.json
+++ b/plugins/discourse-calendar/spec/requests/api/schemas/json/events_index_response.json
@@ -85,6 +85,22 @@
}
},
"required": ["id", "post_number", "url", "category_slug", "topic"]
+ },
+ "occurrences": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "starts_at": {
+ "type": ["string", "null"]
+ },
+ "ends_at": {
+ "type": ["string", "null"]
+ }
+ },
+ "required": ["starts_at", "ends_at"]
+ }
}
},
"required": [
@@ -94,7 +110,8 @@
"ends_at",
"show_local_time",
"timezone",
- "post"
+ "post",
+ "occurrences"
]
}
}
diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rb
index d2a6d207c5c..546b1a8af9f 100644
--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb
+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb
@@ -247,6 +247,118 @@ describe "Post event", type: :system do
expect(page).to have_css(".event-dates", text: "-")
end
+ context "with DST handling for recurring events" do
+ fab!(:viewer) do
+ user = Fabricate(:user)
+ user.user_option.update!(timezone: "Europe/Paris")
+ user
+ end
+
+ it "maintains wall clock time (11:00 AM) in event timezone across all DST transitions" do
+ # Before any DST
+ freeze_time(Time.new(2025, 10, 14, 10, 0, 0, "+02:00")) do
+ post =
+ PostCreator.create!(
+ admin,
+ title: "Weekly recurring event across DST",
+ raw:
+ "[event start='2025-10-15 11:00' timezone='America/New_York' recurrence='every_week']\n[/event]",
+ )
+
+ event = DiscoursePostEvent::Event.find_by(post: post)
+ event.set_next_date
+ sign_in(viewer)
+ visit(post.topic.url)
+
+ expect(page).to have_css(".event-date .month", text: "OCT")
+ expect(page).to have_css(".event-date .day", text: "15")
+ expect(page).to have_css(".discourse-local-date", text: "5:00 PM")
+ end
+
+ # Test 2: After Europe DST
+ freeze_time(Time.new(2025, 10, 28, 10, 0, 0, "+01:00")) do
+ post =
+ PostCreator.create!(
+ admin,
+ title: "Weekly recurring event 2",
+ raw:
+ "[event start='2025-10-15 11:00' timezone='America/New_York' recurrence='every_week']\n[/event]",
+ )
+
+ event = DiscoursePostEvent::Event.find_by(post: post)
+ event.set_next_date
+ sign_in(viewer)
+ visit(post.topic.url)
+
+ expect(page).to have_css(".event-date .month", text: "OCT")
+ expect(page).to have_css(".event-date .day", text: "29")
+ # This is the period where the time CHANGES for European viewers
+ expect(page).to have_css(".discourse-local-date", text: "4:00 PM")
+ end
+
+ # Test 3: After both DST transitions
+ freeze_time(Time.new(2025, 11, 4, 10, 0, 0, "+01:00")) do
+ post =
+ PostCreator.create!(
+ admin,
+ title: "Weekly recurring event 3",
+ raw:
+ "[event start='2025-10-15 11:00' timezone='America/New_York' recurrence='every_week']\n[/event]",
+ )
+
+ event = DiscoursePostEvent::Event.find_by(post: post)
+ event.set_next_date
+ sign_in(viewer)
+ visit(post.topic.url)
+
+ expect(page).to have_css(".event-date .month", text: "NOV")
+ expect(page).to have_css(".event-date .day", text: "5")
+ expect(page).to have_css(".discourse-local-date", text: "5:00 PM")
+ end
+ end
+
+ it "event stays at wall clock time (11:00 AM) in its own timezone throughout DST" do
+ us_viewer = Fabricate(:user)
+ us_viewer.user_option.update!(timezone: "America/New_York")
+
+ # Before US DST ends
+ freeze_time(Time.new(2025, 10, 28, 10, 0, 0, "-04:00")) do
+ post =
+ PostCreator.create!(
+ admin,
+ title: "Weekly recurring event 4",
+ raw:
+ "[event start='2025-10-15 11:00' timezone='America/New_York' recurrence='every_week']\n[/event]",
+ )
+
+ event = DiscoursePostEvent::Event.find_by(post: post)
+ event.set_next_date
+ sign_in(us_viewer)
+ visit(post.topic.url)
+
+ expect(page).to have_css(".discourse-local-date", text: "11:00 AM")
+ end
+
+ # After US DST ends
+ freeze_time(Time.new(2025, 11, 4, 10, 0, 0, "-05:00")) do
+ post =
+ PostCreator.create!(
+ admin,
+ title: "Weekly recurring event 5",
+ raw:
+ "[event start='2025-10-15 11:00' timezone='America/New_York' recurrence='every_week']\n[/event]",
+ )
+
+ event = DiscoursePostEvent::Event.find_by(post: post)
+ event.set_next_date
+ sign_in(us_viewer)
+ visit(post.topic.url)
+
+ expect(page).to have_css(".discourse-local-date", text: "11:00 AM")
+ end
+ end
+ end
+
it "persists changes" do
visit "/new-topic"
composer.fill_title("Test event with updates")
diff --git a/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb b/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb
index 3a67e54e126..973b7a14f1b 100644
--- a/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb
+++ b/plugins/discourse-calendar/spec/system/upcoming_events_spec.rb
@@ -64,14 +64,14 @@ describe "Upcoming Events", type: :system do
end
end
- describe "without local time (UTC events)" do
+ describe "without local time" do
it "displays event time converted to user timezone",
timezone: "Australia/Brisbane",
time: Time.utc(2025, 9, 10, 12, 0) do
create_post(
user: admin,
category: Fabricate(:category),
- title: "Event with UTC time",
+ title: "Event with CET time",
raw:
"[event timezone=CET start=\"2025-09-11 19:00\" end=\"2025-09-11 21:00\"]\n[/event]",
)
@@ -79,9 +79,9 @@ describe "Upcoming Events", type: :system do
upcoming_events.visit
upcoming_events.open_year_view
- expect(upcoming_events).to have_event_with_time("Event with UTC time", "1:00pm - 3:00pm")
+ expect(upcoming_events).to have_event_with_time("Event with CET time", "1:00pm - 3:00pm")
- find("a", text: "Event with UTC time").click
+ find("a", text: "Event with CET time").click
expect(page).to have_css(
".event__section.event-dates",
@@ -159,14 +159,14 @@ describe "Upcoming Events", type: :system do
end
end
- describe "without local time (UTC events)" do
+ describe "without local time" do
it "displays multiple occurrences converted to user timezone",
timezone: "Australia/Brisbane",
time: Time.utc(2025, 9, 10, 12, 0) do
create_post(
user: admin,
category: Fabricate(:category),
- title: "Recurring UTC event",
+ title: "Recurring CET event",
raw:
"[event recurrence=every_week timezone=CET start=\"2025-09-11 19:00\" end=\"2025-09-11 20:00\"]\n[/event]",
)
@@ -184,7 +184,7 @@ describe "Upcoming Events", type: :system do
find(
"tr.fc-list-event:nth-child(2) .fc-list-event-title a",
- text: "Recurring UTC event",
+ text: "Recurring CET event",
).click
expect(page).to have_css(
@@ -196,7 +196,7 @@ describe "Upcoming Events", type: :system do
find(
"tr.fc-list-event:nth-child(4) .fc-list-event-title a",
- text: "Recurring UTC event",
+ text: "Recurring CET event",
).click
expect(page).to have_css(
@@ -264,10 +264,10 @@ describe "Upcoming Events", type: :system do
upcoming_events.visit
upcoming_events.expect_event_count(4)
- upcoming_events.expect_event_at_position(post.topic.title, row: 3, col: 3)
- upcoming_events.expect_event_at_position(post.topic.title, row: 4, col: 3)
- upcoming_events.expect_event_at_position(post.topic.title, row: 5, col: 3)
- upcoming_events.expect_event_at_position(post.topic.title, row: 6, col: 3)
+ upcoming_events.expect_event_at_position(post.topic.title, row: 3, col: 2)
+ upcoming_events.expect_event_at_position(post.topic.title, row: 4, col: 2)
+ upcoming_events.expect_event_at_position(post.topic.title, row: 5, col: 2)
+ upcoming_events.expect_event_at_position(post.topic.title, row: 6, col: 2)
end
end
end
diff --git a/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-outlet-test.js b/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-outlet-test.js
index 1b09a4b5217..a7a6f76b6d6 100644
--- a/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-outlet-test.js
+++ b/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-outlet-test.js
@@ -8,8 +8,6 @@ const eventsPretender = (server, helper) => {
events: [
{
id: 67501,
- starts_at: "2022-04-25T15:14:00.000Z",
- ends_at: "2022-04-30T16:14:00.000Z",
timezone: "Asia/Calcutta",
post: {
id: 67501,
@@ -22,6 +20,12 @@ const eventsPretender = (server, helper) => {
},
},
name: "Awesome Event",
+ occurrences: [
+ {
+ starts_at: "2022-04-25T15:14:00.000Z",
+ ends_at: "2022-04-30T16:14:00.000Z",
+ },
+ ],
},
],
});
diff --git a/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-test.js b/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-test.js
index 782b701f4ea..ed661e655dc 100644
--- a/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-test.js
+++ b/plugins/discourse-calendar/test/javascripts/acceptance/category-events-calendar-test.js
@@ -38,6 +38,28 @@ acceptance("Discourse Calendar - Category Events Calendar", function (needs) {
},
name: "Awesome Event",
rrule: `DTSTART:${moment().format("YYYYMMDDTHHmmss")}Z\nRRULE:FREQ=DAILY;INTERVAL=1;UNTIL=${moment().add(2, "days").format("YYYYMMDD")}`,
+ occurrences: [
+ {
+ starts_at: moment()
+ .tz("Asia/Calcutta")
+ .add(1, "days")
+ .format("YYYY-MM-DDT15:14:00.000Z"),
+ ends_at: moment()
+ .tz("Asia/Calcutta")
+ .add(1, "days")
+ .format("YYYY-MM-DDT16:14:00.000Z"),
+ },
+ {
+ starts_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT15:14:00.000Z"),
+ ends_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT16:14:00.000Z"),
+ },
+ ],
},
{
id: 67502,
@@ -60,6 +82,18 @@ acceptance("Discourse Calendar - Category Events Calendar", function (needs) {
},
},
name: "Awesome Event 2",
+ occurrences: [
+ {
+ starts_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT15:14:00.000Z"),
+ ends_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT16:14:00.000Z"),
+ },
+ ],
},
{
id: 67502,
@@ -82,6 +116,18 @@ acceptance("Discourse Calendar - Category Events Calendar", function (needs) {
},
},
name: "Awesome Event 3<script>alert('my awesome event');</script>",
+ occurrences: [
+ {
+ starts_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT15:14:00.000Z"),
+ ends_at: moment()
+ .tz("Asia/Calcutta")
+ .add(2, "days")
+ .format("YYYY-MM-DDT16:14:00.000Z"),
+ },
+ ],
},
],
});
diff --git a/plugins/discourse-calendar/test/javascripts/acceptance/upcoming-events-calendar-test.js b/plugins/discourse-calendar/test/javascripts/acceptance/upcoming-events-calendar-test.js
index cbdf5b8060d..6ff562ab94f 100644
--- a/plugins/discourse-calendar/test/javascripts/acceptance/upcoming-events-calendar-test.js
+++ b/plugins/discourse-calendar/test/javascripts/acceptance/upcoming-events-calendar-test.js
@@ -34,8 +34,6 @@ acceptance("Discourse Calendar - Upcoming Events Calendar", function (needs) {
events: [
{
id: 67501,
- starts_at: tomorrow().add(1, "hour"),
- ends_at: null,
timezone: "Asia/Calcutta",
post: {
id: 67501,
@@ -49,11 +47,19 @@ acceptance("Discourse Calendar - Upcoming Events Calendar", function (needs) {
name: "Awesome Event",
category_id: 1,
rrule: `DTSTART:${tomorrow().add(1, "hour").format("YYYYMMDDTHHmmss")}Z\nRRULE:FREQ=DAILY;INTERVAL=1;UNTIL=${tomorrow().add(2, "days").format("YYYYMMDD")}`,
+ occurrences: [
+ {
+ starts_at: tomorrow().add(1, "hour"),
+ ends_at: null,
+ },
+ {
+ starts_at: tomorrow().add(1, "day").add(1, "hour"),
+ ends_at: null,
+ },
+ ],
},
{
id: 67502,
- starts_at: tomorrow(),
- ends_at: null,
timezone: "Asia/Calcutta",
post: {
id: 67501,
@@ -66,6 +72,12 @@ acceptance("Discourse Calendar - Upcoming Events Calendar", function (needs) {
},
name: "Another Awesome Event",
category_id: 2,
+ occurrences: [
+ {
+ starts_at: tomorrow(),
+ ends_at: null,
+ },
+ ],
},
],
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index dc2bad3fa6e..d570948f64c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -241,12 +241,12 @@ importers:
'@fullcalendar/list':
specifier: ^6.1.19
version: 6.1.19(@fullcalendar/[email protected])
+ '@fullcalendar/moment':
+ specifier: ^6.1.19
+ version: 6.1.19(@fullcalendar/[email protected])([email protected])
'@fullcalendar/moment-timezone':
specifier: ^6.1.19
version: 6.1.19(@fullcalendar/[email protected])([email protected])
- '@fullcalendar/rrule':
- specifier: ^6.1.18
- version: 6.1.19(@fullcalendar/[email protected])([email protected])
'@fullcalendar/timegrid':
specifier: ^6.1.19
version: 6.1.19(@fullcalendar/[email protected])
@@ -1907,11 +1907,11 @@ packages:
'@fullcalendar/core': ~6.1.19
moment-timezone: ^0.5.40
- '@fullcalendar/[email protected]':
- resolution: {integrity: sha512-8N/QYz2Nuot9oDT9qhtgJwXboX8XaEmtG2PqeSGoSotHIAsWoTXkQ13yXzwwf+3mF0NaQ+RaRQHG//69oo1EEQ==}
+ '@fullcalendar/[email protected]':
+ resolution: {integrity: sha512-wpP0yXSGPDFoY0P3BA6Nw35q/x9TNbnvkwVyu7qgaewepO2Ss10E1yNVM4EtDl82T5IDRcgmFSQ48z1vGcGe1g==}
peerDependencies:
'@fullcalendar/core': ~6.1.19
- rrule: ^2.6.0
+ moment: ^2.29.1
'@fullcalendar/[email protected]':
resolution: {integrity: sha512-OuzpUueyO9wB5OZ8rs7TWIoqvu4v3yEqdDxZ2VcsMldCpYJRiOe7yHWKr4ap5Tb0fs7Rjbserc/b6Nt7ol6BRg==}
@@ -10460,10 +10460,10 @@ snapshots:
'@fullcalendar/core': 6.1.19
moment-timezone: 0.5.45
- '@fullcalendar/[email protected](@fullcalendar/[email protected])([email protected])':
+ '@fullcalendar/[email protected](@fullcalendar/[email protected])([email protected])':
dependencies:
'@fullcalendar/core': 6.1.19
- rrule: 2.8.1
+ moment: 2.30.1
'@fullcalendar/[email protected](@fullcalendar/[email protected])':
dependencies: