Skip to content

feat(calendar): moment to dayjs - #5

Merged
vaebe merged 2 commits into
masterfrom
feat-calendar
Nov 4, 2025
Merged

feat(calendar): moment to dayjs#5
vaebe merged 2 commits into
masterfrom
feat-calendar

Conversation

@vaebe

@vaebe vaebe commented Nov 4, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor

    • Updated the calendar component's date handling and processing for improved performance.
  • Tests

    • Expanded test coverage for calendar navigation, date highlighting, and rendering behavior to ensure reliability.

@coderabbitai

coderabbitai Bot commented Nov 4, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

The changes migrate the calendar component from Moment.js to Day.js for date handling, update package.json dependencies accordingly, and significantly expand the calendar test suite to cover navigation, date selection, and UI interactions using shallow-mounted components.

Changes

Cohort / File(s) Change Summary
Dependency Update
packages/ccui/package.json
Added dayjs ^1.11.19 to dependencies; removed moment ^2.30.1 from devDependencies.
Calendar Component Refactoring
packages/ccui/ui/calendar/src/calendar.tsx
Replaced all Moment.js API calls with Day.js equivalents: weekday()day(), add(n, 'days')add(n, 'day'), startOf('month') for month calculations, and updated date formatting and parsing logic throughout.
Calendar Test Suite Expansion
packages/ccui/ui/calendar/test/calendar.test.ts
Switched from shallowMount to mount with global CButton injection; expanded test coverage to include month navigation, today button behavior, current date highlighting, readOnly propagation, day cell rendering validation, and event emission assertions.

Sequence Diagram

sequenceDiagram
    participant User
    participant Calendar Component
    participant Day.js
    participant State

    Note over User,State: Calendar Initialization
    Calendar Component->>+Day.js: Get current date (dayjs())
    Day.js-->>-Calendar Component: Current date object
    Calendar Component->>State: Store currentDate, currentMonth
    Calendar Component->>Calendar Component: Generate date grid<br/>(startOf('month').day())

    Note over User,State: User Navigation
    User->>Calendar Component: Click next/prev month
    Calendar Component->>+Day.js: Add/subtract month<br/>(add(1, 'month'))
    Day.js-->>-Calendar Component: New month date
    Calendar Component->>State: Update currentMonth
    Calendar Component->>Calendar Component: Regenerate grid
    Calendar Component->>User: Emit date:change event

    Note over User,State: User Selection
    User->>Calendar Component: Click date cell
    Calendar Component->>+Day.js: Format selected date<br/>(format('YYYY-MM-DD'))
    Day.js-->>-Calendar Component: Formatted date string
    Calendar Component->>Calendar Component: Highlight selected date
    Calendar Component->>User: Emit input/change event
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • calendar.tsx: Systematic API migration from Moment.js to Day.js across date arithmetic, formatting, and month/day calculations—verify all method names are correct and edge cases (month boundaries, timezone handling) remain intact.
  • calendar.test.ts: Expanded test coverage with new mount-based tests; validate that all navigation and date selection scenarios are properly exercised and assertions align with expected component behavior.
  • package.json: Confirm Day.js ^1.11.19 compatibility with existing codebase and no lingering Moment.js references.

Poem

🐰 ✨ We've cast off Moment's heavy cloak,
Day.js swift and light awoke—
Lighter hops, faster time,
Each calendar day now so sublime!
Tests bloom bright, coverage expands with glee,
A nimbler date library it shall be! 🕐

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-calendar

📜 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 4d86c96 and c3b604d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/ccui/package.json (1 hunks)
  • packages/ccui/ui/calendar/src/calendar.tsx (8 hunks)
  • packages/ccui/ui/calendar/test/calendar.test.ts (4 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@vaebe
vaebe merged commit 2974deb into master Nov 4, 2025
1 of 2 checks passed
@vaebe
vaebe deleted the feat-calendar branch November 4, 2025 13:08
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.

1 participant