Skip to content

Datetime properties handling #1

Description

@PhilflowIO

Problem

Currently, updating datetime properties (DTSTART, DTEND, DUE, etc.) with string values fails because ical.js validates and decorates these properties automatically.

Example

// This throws: "invalid date-time value"
updateFields(event, {
  'DTSTART': '20250130T140000Z'
});

Root Cause

ical.js updatePropertyWithValue() attempts to parse datetime strings and validate them, which conflicts with our field-agnostic approach.

Potential Solutions

  1. Document workaround: Users update datetimes separately using ical.js directly
  2. Special handling: Detect datetime properties and use ical.js Time objects
  3. Leave as-is: Keep library truly field-agnostic, datetime is user responsibility

Philosophy Alignment

Option 3 aligns best with "parse anything, write anything" - datetime complexity belongs in application layer, not this utility library.

Workaround

import ICAL from 'ical.js';

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

// Update datetime using ical.js
const newStart = ICAL.Time.fromString('20250130T140000Z');
vevent.updatePropertyWithValue('dtstart', newStart);

// Update other fields using tsdav-utils
const updated = updateFields(component.toString(), {
  'SUMMARY': 'Updated Title',
  'LOCATION': 'New Location'
});

Related

  • RFC 5545 Section 3.3.5 (DATE-TIME)
  • ical.js Time documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions