Skip to content

Write date-times in a named time zone (TZID + VTIMEZONE) #4

Closed

Description

@PhilflowIO

Problem

Timezone handling in iCalendar is complex, involving:

  • VTIMEZONE components
  • TZID parameters
  • UTC vs local time
  • All-day events vs timed events
  • Daylight saving time transitions

Current Behavior

Library makes no attempt to handle timezone complexity. Properties are updated as-is.

Challenges

1. VTIMEZONE Components

BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:America/New_York
BEGIN:STANDARD
DTSTART:20231105T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=America/New_York:20250128T140000
END:VEVENT
END:VCALENDAR

2. All-day vs Timed Events

DTSTART;VALUE=DATE:20250128          # All-day
DTSTART:20250128T140000Z              # UTC
DTSTART;TZID=America/New_York:20250128T140000  # Local

Potential Solutions

  1. Document only - Users handle timezone in application layer
  2. Helper functions - Provide utilities for common timezone operations
  3. Integration - Work with libraries like Luxon/date-fns

Philosophy Alignment

Option 1 aligns best with our minimalist approach. Timezone logic is complex and opinionated, doesn't belong in a "dumb glue" library.

Workaround

Store in UTC

// Application converts to UTC before calling
const utcTime = convertToUTC(userInputTime, userTimezone);
updateFields(event, {
  'DTSTART': utcTime  // Already in iCal format
});

Use ical.js for timezone-aware operations

import ICAL from 'ical.js';

// Parse and handle timezone
const component = new ICAL.Component(ICAL.parse(event.data));
const vevent = component.getFirstSubcomponent('vevent');

// Use ical.js Time with timezone
const time = ICAL.Time.fromJSDate(new Date(), true);  // UTC
vevent.updatePropertyWithValue('dtstart', time);

// Update other fields with tsdav-utils
const updated = updateFields(component.toString(), {
  'SUMMARY': 'Meeting'
});

Best Practice

Recommend in README:

  • Store all times in UTC
  • Convert to local timezone in UI layer
  • Keep timezone logic separate from iCal manipulation

Related

  • RFC 5545 Section 3.6.5 (Time Zone Component)
  • RFC 5545 Section 3.3.5 (DATE-TIME)
  • RFC 5545 Section 3.2.19 (TZID Parameter)

Activity

  1. added
    enhancement
    on Oct 27, 2025
  2. PhilflowIO commented on Oct 8, 2026

    @PhilflowIO
    OwnerAuthor

    Status after 0.4.x–0.6.0: most of this issue is done, one part is open.

    Done

    • Date-typed properties are parsed and written typed: VALUE=DATE vs date-time, UTC, floating, and an existing TZID is kept for zoneless input (0.4.x).
    • DTEND/DUE/EXDATE/RDATE/RECURRENCE-ID follow DTSTART's zone and value type.
    • VTIMEZONE components are read with correct DST transitions in both directions (own conversion, because ical.js 2.2.1 gets UTC→local wrong near transitions: Timezone DTSTART is interpreted as UTC kewisch/ical.js#847, fix submitted as Look up the offset of UTC times as UTC when converting between zones kewisch/ical.js#1050); IANA names without a VTIMEZONE are resolved via Intl (0.5.0).
    • Moving a recurring series is DST-aware on the series' wall clock (0.5.0).
    • absoluteTime: 'keep-zone' keeps an existing TZID when a Z/offset value is written (0.6.0).

    Still open: producing a named zone. The library can keep a TZID that is already there, but cannot introduce one: a new value given as Z/offset is written as UTC, a zoneless one as floating (or host time → UTC). For a new recurring meeting that means a UTC series whose local time shifts by an hour at every DST change. dav-mcp's create_event hits exactly this.

    Proposed scope for this issue:

    • An option to write date-times in a named IANA zone (e.g. zone: 'Europe/Berlin'): the value is converted to wall time in that zone (DST gap/fold per RFC 5545 §3.3.5), written with TZID, and a matching VTIMEZONE is added to the VCALENDAR if missing (RFC 5545 §3.6.5 requires one per TZID; check RFC 7809 for omission rules).
    • Tests against Intl for several zones; a generated VTIMEZONE must round-trip through ical.js and the library's own reader.
    • README: replace the "Known limitations → Timezone handling" entry and the "store all times in UTC" advice.

    Consumer side: dav-mcp create_event/update_event get a timezone (default from the calendar's calendar-timezone, see PhilflowIO/dav-mcp#117).

  3. changed the title [-]Timezone handling complexity[/-] [+]Write date-times in a named time zone (TZID + VTIMEZONE)[/+] on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions