> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# consistent-date-clone

[Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ unicornPlugin.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/consistent-date-clone': 'error',
    },
  },
]);
```

## Rule Details

Prefer passing an existing `Date` directly to the `Date` constructor when
cloning it. Since ECMAScript 2015, `new Date(date)` copies the original date's
time value without requiring an intermediate number.

Examples of **incorrect** code for this rule:

```javascript
const copy = new Date(date.getTime());
```

Examples of **correct** code for this rule:

```javascript
const copy = new Date(date);
```

The rule only reports the direct `new Date(date.getTime())` shape. Calls with
additional constructor arguments or component-wise date construction are left
unchanged:

```javascript
new Date(date.getTime(), extraArgument);

new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDate(),
  date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
);
```

## Original Documentation

- [eslint-plugin-unicorn: consistent-date-clone](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v74.0.0/docs/rules/consistent-date-clone.md)
- [Source code](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v74.0.0/rules/consistent-date-clone.js)
