mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-14 20:55:15 +02:00
fix: refine date handling in Google Calendar connector to ensure accurate same-day queries
This commit is contained in:
parent
4526b656a4
commit
9771a88380
2 changed files with 7 additions and 21 deletions
|
|
@ -246,15 +246,18 @@ class GoogleCalendarConnector:
|
|||
dt_start = isoparse(start_date)
|
||||
dt_end = isoparse(end_date)
|
||||
|
||||
# Set start to beginning of day (00:00:00) and end to end of day (23:59:59)
|
||||
# This ensures same-date queries work (e.g., start=2026-01-23, end=2026-01-23)
|
||||
# and matches the Composio connector behavior
|
||||
if dt_start.tzinfo is None:
|
||||
dt_start = dt_start.replace(tzinfo=pytz.UTC)
|
||||
dt_start = dt_start.replace(hour=0, minute=0, second=0, tzinfo=pytz.UTC)
|
||||
else:
|
||||
dt_start = dt_start.astimezone(pytz.UTC)
|
||||
dt_start = dt_start.astimezone(pytz.UTC).replace(hour=0, minute=0, second=0)
|
||||
|
||||
if dt_end.tzinfo is None:
|
||||
dt_end = dt_end.replace(tzinfo=pytz.UTC)
|
||||
dt_end = dt_end.replace(hour=23, minute=59, second=59, tzinfo=pytz.UTC)
|
||||
else:
|
||||
dt_end = dt_end.astimezone(pytz.UTC)
|
||||
dt_end = dt_end.astimezone(pytz.UTC).replace(hour=23, minute=59, second=59)
|
||||
|
||||
if dt_start >= dt_end:
|
||||
return [], (
|
||||
|
|
|
|||
|
|
@ -209,23 +209,6 @@ async def index_google_calendar_events(
|
|||
start_date_str = start_date
|
||||
end_date_str = end_date
|
||||
|
||||
# If start_date and end_date are the same, adjust end_date to be one day later
|
||||
# to ensure valid date range (start_date must be strictly before end_date)
|
||||
if start_date_str == end_date_str:
|
||||
# Parse the date and add one day to ensure valid range
|
||||
dt = isoparse(end_date_str)
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=pytz.UTC)
|
||||
else:
|
||||
dt = dt.astimezone(pytz.UTC)
|
||||
# Add one day to end_date to make it strictly after start_date
|
||||
dt_end = dt + timedelta(days=1)
|
||||
end_date_str = dt_end.strftime("%Y-%m-%d")
|
||||
logger.info(
|
||||
f"Adjusted end_date from {end_date} to {end_date_str} "
|
||||
f"to ensure valid date range (start_date must be strictly before end_date)"
|
||||
)
|
||||
|
||||
await task_logger.log_task_progress(
|
||||
log_entry,
|
||||
f"Fetching Google Calendar events from {start_date_str} to {end_date_str}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue