Complete calendar model refactor to use NaiveDateTime for local time handling
- Refactor VEvent to use NaiveDateTime for all date/time fields (dtstart, dtend, created, etc.) - Add separate timezone ID fields (_tzid) for proper RFC 5545 compliance - Update all handlers and services to work with naive local times - Fix external calendar event conversion to handle new model structure - Remove UTC conversions from frontend - backend now handles timezone conversion - Update series operations to work with local time throughout the system - Maintain compatibility with existing CalDAV servers and RFC 5545 specification This major refactor simplifies timezone handling by treating all event times as local until the final CalDAV conversion step, eliminating multiple conversion points that caused timing inconsistencies. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -285,17 +285,25 @@ fn convert_ical_to_vevent(ical_event: IcalEvent) -> Result<VEvent, Box<dyn std::
|
||||
|
||||
let vevent = VEvent {
|
||||
uid: uid.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
||||
dtstart,
|
||||
dtend,
|
||||
dtstart: dtstart.naive_utc(),
|
||||
dtstart_tzid: None, // TODO: Parse timezone from ICS
|
||||
dtend: dtend.map(|dt| dt.naive_utc()),
|
||||
dtend_tzid: None, // TODO: Parse timezone from ICS
|
||||
summary,
|
||||
description,
|
||||
location,
|
||||
all_day,
|
||||
rrule,
|
||||
rdate: Vec::new(),
|
||||
rdate_tzid: None,
|
||||
exdate: Vec::new(), // External calendars don't need exception handling
|
||||
exdate_tzid: None,
|
||||
recurrence_id: None,
|
||||
recurrence_id_tzid: None,
|
||||
created: None,
|
||||
created_tzid: None,
|
||||
last_modified: None,
|
||||
last_modified_tzid: None,
|
||||
dtstamp: Utc::now(),
|
||||
sequence: Some(0),
|
||||
status: None,
|
||||
@@ -313,7 +321,6 @@ fn convert_ical_to_vevent(ical_event: IcalEvent) -> Result<VEvent, Box<dyn std::
|
||||
class: None,
|
||||
contact: None,
|
||||
comment: None,
|
||||
rdate: Vec::new(),
|
||||
alarms: Vec::new(),
|
||||
etag: None,
|
||||
href: None,
|
||||
@@ -834,7 +841,7 @@ fn would_event_be_generated_by_rrule(recurring_event: &VEvent, single_event: &VE
|
||||
if rrule.contains("FREQ=DAILY") {
|
||||
// Daily recurrence
|
||||
let interval = extract_interval_from_rrule(rrule).unwrap_or(1);
|
||||
let days_diff = (single_event.dtstart.date_naive() - recurring_event.dtstart.date_naive()).num_days();
|
||||
let days_diff = (single_event.dtstart.date() - recurring_event.dtstart.date()).num_days();
|
||||
|
||||
if days_diff >= 0 && days_diff % interval as i64 == 0 {
|
||||
// Check if times match (allowing for timezone differences within same day)
|
||||
@@ -845,7 +852,7 @@ fn would_event_be_generated_by_rrule(recurring_event: &VEvent, single_event: &VE
|
||||
} else if rrule.contains("FREQ=WEEKLY") {
|
||||
// Weekly recurrence
|
||||
let interval = extract_interval_from_rrule(rrule).unwrap_or(1);
|
||||
let days_diff = (single_event.dtstart.date_naive() - recurring_event.dtstart.date_naive()).num_days();
|
||||
let days_diff = (single_event.dtstart.date() - recurring_event.dtstart.date()).num_days();
|
||||
|
||||
// First check if it's the same day of week and time
|
||||
let recurring_weekday = recurring_event.dtstart.weekday();
|
||||
|
||||
Reference in New Issue
Block a user