Skip to content

More calendar timezone fixes, datetime handling fixes - #570

Open
daym wants to merge 7 commits into
llazzaro:developfrom
daym:update
Open

More calendar timezone fixes, datetime handling fixes#570
daym wants to merge 7 commits into
llazzaro:developfrom
daym:update

Conversation

@daym

@daym daym commented Feb 18, 2026

Copy link
Copy Markdown
Contributor
  • More calendar timezone fixes
  • datetime handling fixes for recurrences (for USE_TZ=False and for USE_TZ=True)
  • Add Event.updater field

Principles:

  • When you specify recurring events as a human you want to specify it in local time (since it recurs at the same time in local time regardless of summer-/wintertime changes--for example: in summer, the event starts at 10:00. In winter, the event starts at 10:00 too). Since the rfc generator used for generating events only supports naive datetimes that is modeled with naive datetimes. Have to use those for the rfc generator and eventually convert them to timezone-aware at the boundaries
  • Timestamps stored in the database are stored as timestamp with time zone in postgres (which For timestamp with time zone , the internally stored value is always in UTC according to postgres docs) AND I now store a timezone string into the database table schedule_event as well (pytz really wants you to use named timezones--which makes sense because there can be other local variations depending on politics, so the timezone offset is not uniquely identifying what you have to do).
  • Python stdlib directly supports datetime with time zone name only starting with python 3.12--which I think is a little too new to require. So I avoid using its features here.

@coveralls

coveralls commented Feb 18, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 85.26%. first build
when pulling d922193 on daym:update
into bcb48e3 on llazzaro:develop.

@daym
daym force-pushed the update branch 4 times, most recently from f5563b6 to 4a58583 Compare February 18, 2026 19:00
@llazzaro

Copy link
Copy Markdown
Owner

Hi @daym ,

Thanks for creating this PR, I really appreciate the effort.

Would it be possible to split it into smaller changes? It currently includes several features together, which makes it harder to review and merge. If there is an issue in one part, we cannot merge the others that may already be ready.

Since this project is used in legacy systems, even small changes can affect existing users. Smaller PRs would make it easier and safer to review and integrate.

Thanks again for your work!

@daym daym changed the title More calendar timezone fixes, Fullcalendar API, datetime handling fixes More calendar timezone fixes, datetime handling fixes Feb 18, 2026
@daym

daym commented Feb 18, 2026

Copy link
Copy Markdown
Contributor Author

Would it be possible to split it into smaller changes? It currently includes several features together, which makes it harder to review and merge. If there is an issue in one part, we cannot merge the others that may already be ready.

I've now split out the things that need no DB migration--but with the other ones I cannot really split them up because the migrations have (spurious, but django likes it) dependencies.

@daym
daym force-pushed the update branch 3 times, most recently from 665a0e6 to 6e599d7 Compare February 18, 2026 20:21
daym added 4 commits February 18, 2026 21:28
Add RuleParam and RuleParamVariant models to enable UI-driven recurrence
rule creation instead of manually editing the opaque params text field.

- Add RuleParam model (name, display_string)
- Add RuleParamVariant model (param FK, value, value_display_string)
- Add Rule.repeats ManyToManyField to RuleParamVariant
- Make Rule.name unique with max_length=255
- Add Rule.ensure_rule() classmethod for find-or-create
- Add RuleAdmin fields and filter_horizontal for repeats
- Update tests for unique Rule.name constraint
Add updater ForeignKey field to Event model for audit trail in
collaborative editing. Also update creator related_name to
created_events for consistency.
Add color_event CharField to Calendar model for FullCalendar display
colors. Add CalendarForm with ColorInput widget, update CalendarAdmin
fieldsets, and add ordering by name to Calendar.Meta.
Add timezone CharField to Event for DST-correct recurrences. Refactor
rrule generation to use event-local naive datetimes. Add _localize()
helper. Add event_tzinfo property using ZoneInfo. Add database-level
CheckConstraint ensuring end >= start. Update tests for new timezone
handling and occurrence hash/equality semantics.
daym added 3 commits February 20, 2026 09:31
Replace pytz with stdlib datetime.timezone.utc in _normalize_timezone_to_utc.
Use utc_start/utc_end for occurrence filtering in Period class. Add
rule__repeats to prefetch_related for O(1) query count. Remove pytz
from project dependencies.
Switch models/__init__.py to relative imports.
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.

3 participants