Skip to content

Conversation

@GreatAuk
Copy link
Contributor

@GreatAuk GreatAuk commented Nov 7, 2025

Description

image 这样定义类型, 编辑器上有代码提示,而且也可以自定义,不会类型报错
formatDate(new Date, 'HHcc')

commit 信息被我搞乱了,但真正更新的文件只有一个。所以合并时请选择 "Squash and Merge"

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Improvements
    • Date formatting functions now accept optional time parameters and support expanded format token options.
    • Invalid dates now trigger error handling instead of silent failures, improving data validation.

@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

⚠️ No Changeset found

Latest commit: 85b85bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Walkthrough

The date utility module now accepts optional time parameters in formatDate and formatDateTime, introduces a new internal Format type for flexible format specifications, and enhances error handling by raising exceptions for invalid dates instead of silently proceeding.

Changes

Cohort / File(s) Summary
Date Utility Refactoring
packages/@core/base/shared/src/utils/date.ts
Added internal Format union type for date format tokens; made time parameter optional in formatDate and formatDateTime; changed error handling in formatDate to throw on invalid dates instead of silent fallback; adjusted control flow with nullish-coalescing defaults

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant formatDate

    rect rgb(200, 220, 255)
    Note over Caller,formatDate: New Flow
    Caller->>formatDate: formatDate(time?, format)
    alt time is provided
        formatDate->>formatDate: Validate input
        alt Validation passes
            formatDate->>Caller: Return formatted string
        else Validation fails
            formatDate->>Caller: Throw error
        end
    else time is undefined
        formatDate->>Caller: Return stringified time (nullish coalescing)
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • API signature changes: Breaking changes to formatDate and formatDateTime signatures; verify all call sites and dependent code handle optional time parameter correctly
  • Error handling logic: New error-throwing behavior differs from previous silent handling; ensure clients are prepared for exceptions
  • Type system changes: New internal Format type impacts type inference and validation; review format token coverage and type constraints
  • Backward compatibility: Check if any existing integrations rely on the old function signatures or silent error behavior

Suggested reviewers

  • anncwb
  • vince292007
  • mynetfan

Poem

🐰 Dates now flow with graceful bounds,
Optional time in softer sounds,
Errors raised when things go wrong,
Format tokens, strong and long,
Timestamps hop through time once more!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description is incomplete; multiple required checklist items are unchecked (documentation, testing, self-review, etc.), and no evidence is provided that these tasks were completed. Provide evidence or confirmation that the tasks in the checklist have been completed, or check the relevant boxes once completed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Enhance util-formatDate ts type hints' accurately describes the main change: improving TypeScript type support for the formatDate function.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 1e09fa4 and 85b85bc.

📒 Files selected for processing (1)
  • packages/@core/base/shared/src/utils/date.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Check (windows-latest)
  • GitHub Check: Lint (ubuntu-latest)
  • GitHub Check: Lint (windows-latest)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
🔇 Additional comments (1)
packages/@core/base/shared/src/utils/date.ts (1)

10-20: Nice use of literal-augmented format hints.

The 'HH' | ... | (string & {}) pattern gives callers rich IDE completions while still accepting any custom format string—great fit for this helper.


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.

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