Aalexbit-codemod

cal-timezone-date-mining

Read-only mining codemod for timezone-sensitive date handling in Cal.com-style TypeScript codebases. Detects date-only parsing, Date.parse, locale formatting, dayjs day boundaries, and Prisma query date comparisons without modifying source.

cal.comtimezonedateprismadayjsmetricsmining
Public
0 executions

Run locally

npx codemod cal-timezone-date-mining

cal-timezone-date-mining

Read-only mining codemod for timezone-sensitive date handling patterns, tailored to Cal.com-style TypeScript codebases.

Detection only — does not modify source code.

Why this exists

Cal.com schedules bookings across timezones using Prisma (startTime, endTime, createdAt), @calcom/dayjs, and API date filters. Patterns like new Date("YYYY-MM-DD") or local startOf("day") can pass mocked tests but fail under server timezone, database timezone, DST, or UTC conversion differences.

Metric

Single metric atom: timezone-date-handling

CardinalityDescription
patternAPI smell: new_date_date_only, date_parse, to_locale_string, date_to_string, dayjs_date_only, dayjs_day_boundary
queryFieldCal.com Prisma field when used in a query boundary (startTime, endTime, createdAt, …) or none
queryOpPrisma comparator (gte, lte, gt, lt) or none
riskhigh (in query boundary), medium, or low
inQueryBoundarytrue when the value feeds a Prisma date filter
fileRelative file path
line1-based line of the anchor expression
snippetTruncated source excerpt

Cal.com-tailored detection

Built from repo scan findings:

  • Booking Prisma fields: startTime, endTime, createdAt, updatedAt, periodStart*, highWaterMarkPeriodStart, …
  • dayjs / @calcom/dayjs: date-only literals and local startOf("day") / endOf("day") (excludes .utc() chains)
  • API filter parsing: Date.parse in handlers (e.g. insights / voice-agent date filters)
  • Locale formatting: .toLocaleString() in UI and email templates

Exclusions

  • Explicit UTC / offset timestamps (2026-05-25T00:00:00.000Z) for constructors and Date.parse
  • dayjs.utc(...).startOf("day") and similar UTC-safe chains
  • Test files (*.test.ts, *.spec.ts, integration tests) via workflow excludes

Usage

bash

Example finding

typescript

Emitted metric cardinality:

json

Development

bash

Ready to contribute?

Build your own codemod and share it with the community.