Skip to content

Fix event sorting by timezone-aware display time#62

Closed
CR0CKER wants to merge 4 commits intosawhney17:mainfrom
CR0CKER:fix-timezone-event-sorting
Closed

Fix event sorting by timezone-aware display time#62
CR0CKER wants to merge 4 commits intosawhney17:mainfrom
CR0CKER:fix-timezone-event-sorting

Conversation

@CR0CKER
Copy link
Copy Markdown

@CR0CKER CR0CKER commented Jan 12, 2026

Summary

This PR fixes a bug where calendar events were not appearing in the correct chronological order when events from different timezones were present on the same day.

Changes

  • Filter invalid dates: Events with invalid dates are now filtered out before sorting to prevent NaN comparison errors
  • Timezone-aware sorting: Events are now sorted by their displayed time in their original timezone, not by absolute timestamps
  • Fix recurring event timezone conversion: Improved timezone handling for recurring events using moment.tz object notation
  • Correct insertion order: Fixed the order in which events are inserted to match the chronological sort order

Example

Before this fix, events on the same day would appear incorrectly:

  • 13:45 - Event A
  • 16:00 - Event B
  • 14:30 - Event C (created in different timezone)

After this fix, they appear in correct chronological order:

  • 13:45 - Event A
  • 14:30 - Event C
  • 16:00 - Event B

Testing

Tested with multiple calendars containing events in different timezones (Central European Standard Time, Central European Summer Time, etc.) and confirmed events now sort correctly by their displayed time.

🤖 Generated with Claude Code

CR0CKER and others added 4 commits December 9, 2025 11:15
- Fixed hardcoded date range (2021-2023) in recurring event generation
  Now dynamically generates events from 1 year ago to 2 years in future
- Fixed timezone handling for recurring events with tzid
- Added null check in parseLocation() to prevent "TypeError: b is not iterable"
  when event locations don't contain URLs
- Added cache-busting headers to force fresh calendar data

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This is the confirmed working version of the plugin.

Bug fixes included:
- Fixed hardcoded date range (2021-2023) for recurring events
  Now dynamically generates from 1 year ago to 2 years in future
- Fixed timezone handling for recurring events with tzid
- Fixed parseLocation() null check preventing "TypeError: b is not iterable"
- Removed CORS-triggering headers (Cache-Control, Pragma, Expires)
- Added cache-busting URL parameter for fresh calendar data

Build configuration:
- Added .parcelrc configuration
- Built with Node 16.20.2 using NVM
- Updated package-lock.json with esbuild dev dependency

Deployment:
- Plugin works in Developer mode (file:// protocol)
- Load as unpacked plugin from source directory
- Tested and confirmed working on December 9, 2025

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…sion

Recurring events with timezone information (tzid) were being displayed with incorrect times because the timezone was lost during JavaScript Date conversion. This caused events to be shown in the local system timezone instead of the event's original timezone.

Changes:
- Preserve timezone info in recurring event objects
- Update formatTime() to accept optional timezone parameter and use moment-timezone for accurate time extraction
- Calculate end times correctly for recurring events based on original duration
- Pass timezone info through the formatting pipeline

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Filter out events with invalid dates to prevent NaN comparisons
- Sort events by displayed time in their original timezone, not absolute timestamps
- Fix timezone conversion for recurring events using moment.tz object notation
- Correct insertion order to match chronological sort order

This ensures events appear in the correct chronological order (e.g., 13:45, 14:30, 16:00)
even when events are created in different timezones.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@CR0CKER
Copy link
Copy Markdown
Author

CR0CKER commented Feb 5, 2026

Closing this PR as it has been superseded by #63, which includes this fix along with several other related improvements:

  • Filter declined events
  • Filter deleted/cancelled events
  • Fix rescheduled recurring events
  • Fix timezone display for recurring events
  • Fix event sorting (this PR's changes)

Please review #63 instead for a comprehensive set of calendar improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant