Fix all-day recurring events RFC-5545 compliance
- Set all_day flag properly when creating VEvent in series handler - Improve all-day event detection using VALUE=DATE parameter - Add RFC-5545 compliance for exclusive end dates (backend adds 1 day) - Fix end date display in event modal (frontend subtracts 1 day for display) - Fix recurring all-day event expansion to maintain proper end date pattern 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,7 @@ pub fn EventModal(props: &EventModalProps) -> Html {
|
||||
html! {
|
||||
<div class="event-detail">
|
||||
<strong>{"End:"}</strong>
|
||||
<span>{format_datetime(end, event.all_day)}</span>
|
||||
<span>{format_datetime_end(end, event.all_day)}</span>
|
||||
</div>
|
||||
}
|
||||
} else {
|
||||
@@ -221,6 +221,17 @@ fn format_datetime(dt: &DateTime<Utc>, all_day: bool) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn format_datetime_end(dt: &DateTime<Utc>, all_day: bool) -> String {
|
||||
if all_day {
|
||||
// For all-day events, subtract one day from end date for display
|
||||
// RFC-5545 uses exclusive end dates, but users expect inclusive display
|
||||
let display_date = *dt - chrono::Duration::days(1);
|
||||
display_date.format("%B %d, %Y").to_string()
|
||||
} else {
|
||||
dt.format("%B %d, %Y at %I:%M %p").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn format_recurrence_rule(rrule: &str) -> String {
|
||||
// Basic parsing of RRULE to display user-friendly text
|
||||
if rrule.contains("FREQ=DAILY") {
|
||||
|
||||
@@ -439,9 +439,17 @@ impl CalendarService {
|
||||
let mut occurrence_event = base_event.clone();
|
||||
occurrence_event.dtstart = occurrence_datetime;
|
||||
occurrence_event.dtstamp = chrono::Utc::now(); // Update DTSTAMP for each occurrence
|
||||
|
||||
|
||||
if let Some(end) = base_event.dtend {
|
||||
occurrence_event.dtend = Some(end + Duration::days(days_diff));
|
||||
if let Some(base_end) = base_event.dtend {
|
||||
if base_event.all_day {
|
||||
// For all-day events, maintain the RFC-5545 end date pattern
|
||||
// End date should always be exactly one day after start date
|
||||
occurrence_event.dtend = Some(occurrence_datetime + Duration::days(1));
|
||||
} else {
|
||||
// For timed events, preserve the original duration
|
||||
occurrence_event.dtend = Some(base_end + Duration::days(days_diff));
|
||||
}
|
||||
}
|
||||
|
||||
occurrences.push(occurrence_event);
|
||||
|
||||
Reference in New Issue
Block a user