Skip to content

Conversation

@muness
Copy link
Member

@muness muness commented Sep 23, 2025

#192 - Add a task to down Official Unicode CLDR Mappings. Use them to pre-process VEVENTS if ical-node throws a "TypeError: N.startsWith is not a function" error

Summary by CodeRabbit

  • New Features

    • Improved ICS calendar parsing with automatic mapping of Microsoft/Windows timezones to IANA, enhancing compatibility with Office 365 invites and reducing timezone-related failures.
    • More robust handling of recurrence and RECURRENCE-ID events with Microsoft timezones.
  • Bug Fixes

    • Resolved parsing errors caused by malformed or unrecognized timezone identifiers, preventing crashes and retries gracefully.
  • Tests

    • Added extensive test coverage for Microsoft timezone scenarios, recurrence overrides, and mapping coverage.
  • Chores

    • Added an npm script to update timezone mappings automatically.

…ocess VEVENTS if ical-node throws a "TypeError: N.startsWith is not a function" error
@muness muness self-assigned this Sep 23, 2025
@muness muness added the enhancement New feature or request label Sep 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a timezone update script and npm entry, introduces ICS preprocessing to map Windows to IANA timezones with retry-on-error parsing, generates mapping artifacts, and adds extensive tests validating Microsoft timezone handling and mapping coverage.

Changes

Cohort / File(s) Summary
Scripts & npm
package.json
Adds npm script update-timezones mapped to node scripts/update-timezones.js.
Timezone mapping generator
scripts/update-timezones.js, src/generated/windowsTimezones.ts, src/generated/windows-to-iana.json, src/generated/windows-to-iana.yaml
New script fetches CLDR WindowsZones, parses primary Windows→IANA mappings, and writes generated TS module, JSON metadata, and YAML mapping files with basic error handling and logging.
ICS preprocessing for Windows TZIDs
src/icalUtils.ts
Adds preprocessing to rewrite Windows/Microsoft TZIDs to IANA before parsing; parseIcs now retries parsing after a targeted TypeError, preserving original signature.
Tests for Microsoft timezones
tests/microsoft-timezone.test.ts
Adds tests covering retry flow, mapping coverage, recurrence cases, and various Microsoft timezone names; includes mocking of node-ical and some skipped tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant ICS as parseIcs
  participant NodeIcal as node-ical.parseICS
  participant Pre as Preprocessor (Windows→IANA)

  Caller->>ICS: parseIcs(ics)
  ICS->>NodeIcal: parseICS(ics)
  alt Parse succeeds
    NodeIcal-->>ICS: events
    ICS-->>Caller: events
  else TypeError with TZID (e.g., tz.startsWith)
    ICS->>Pre: preprocess(ics) // rewrite Windows TZIDs to IANA
    Pre-->>ICS: ics'
    ICS->>NodeIcal: parseICS(ics')
    alt Retry succeeds
      NodeIcal-->>ICS: events
      ICS-->>Caller: events
    else Retry fails
      ICS-->>Caller: throw combined error
    end
  else Other errors
    ICS-->>Caller: rethrow error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nibbled through zones from Redmond to Rome,
Mapping their names to IANA’s true home.
A hiccup? I retry—hop, parse, and glide,
With CLDR carrots tucked by my side.
Tests bloom like clover—green fields I see,
Time tastes delicious to a dev bunny. 🥕⏰

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-microsoft-timezone-parsing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d9becc and 85bbb7c.

⛔ Files ignored due to path filters (3)
  • src/generated/windows-to-iana.json is excluded by !**/generated/**
  • src/generated/windows-to-iana.yaml is excluded by !**/generated/**
  • src/generated/windowsTimezones.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • scripts/update-timezones.js (1 hunks)
  • src/icalUtils.ts (2 hunks)
  • tests/microsoft-timezone.test.ts (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@muness muness merged commit b17750b into master Sep 23, 2025
1 check was pending
@muness muness deleted the fix-microsoft-timezone-parsing branch September 23, 2025 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants