Fixed an error in certain environments caused by d.mts files exporting only types.
v3.0.0
Changed
BREAKING: date-fns is now a dual-package with the support of both ESM and CommonJS. The files exports are now explicitly in the package.json. The ESM files now have .mjs extension.
BREAKING: The package now has a flat structure, meaning functions are now named node_modules/date-fns/add.mjs, locales are node_modules/date-fns/locale/enUS.mjs, etc.
BREAKING: Now all file content’s exported via named exports instead of export default, which will require change direct imports i.e. const addDays = require(‘date-fns/addDays’) to const { addDays } = require(‘date-fns/addDays’).
BREAKING: TypeScript types are now completely rewritten, check out the d.ts files for more information.
BREAKING: constants now is not exported via the index, so to import one use import { daysInYear } from "date-fns/constants";. It improves compatibility with setups that modularize imports like Next.js.
BREAKING: Functions now don’t check the number of passed arguments, delegating this task to type checkers. The functions are now slimmer because of this.
BREAKING The arguments are not explicitly converted to the target types. Instead, they are passed as is, delegating this task to type checkers.
BREAKING: Functions that accept Interval arguments now do not throw an error if the start is before the end and handle it as a negative interval. If one of the properties in an Invalid Date, these functions also do not throw and handle them as invalid intervals.
areIntervalsOverlapping normalize intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. When comparing intervals with one of the properties being Invalid Date, the function will return false unless the others are valid and equal, given the inclusive option is passed. Otherwise, and when even one of the intervals has both properties invalid, the function will always return false.
getOverlappingDaysInIntervals now normalizes intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. If any of the intervals’ properties is an Invalid Date, the function will always return 0.
isWithinInterval now normalizes intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. If any of the intervals’ properties is an Invalid Date, the function will always return false.
intervalToDuration now returns negative durations for negative intervals. If one or both of the interval properties are invalid, the function will return an empty object.
The eachXOfInterval functions (eachDayOfInterval, eachHourOfInterval, eachMinuteOfInterval, eachMonthOfInterval, eachWeekendOfInterval, eachWeekendOfMonth, eachWeekendOfYear, eachWeekOfInterval, eachYearOfInterval) now return a reversed array if the passed interval’s start is after the end. Invalid properties will result in an empty array. Functions that accept the step option now also allow negative, 0, and NaN values and return reversed results if the step is negative and an empty array otherwise.
BREAKING: intervalToDuration now skips 0 values in the resulting duration, resulting in more compact objects with only relevant properties.
BREAKING: roundToNearestMinutes now returns Invalid Date instead of throwing an error when nearestTo option is less than 1 or more than 30.
BREAKING: IE is no longer supported.
BREAKING: Now all functions use Math.trunc rounding method where rounding is required. The behavior is configurable on a per-function basis.
BREAKING: Undocumented onlyNumeric option was removed from nn and sv locales. If you relied on it, please contact me.
BREAKING: Flow is not supported anymore. If you relied on it, please contact me.
BREAKING: The locales now use regular functions instead of the UTC version, which should not break any code unless you used locales directly.
Fixed an error in certain environments caused by d.mts files exporting only types.
v3.0.0 - 2023-12-18
Changed
BREAKING: date-fns is now a dual-package with the support of both ESM and CommonJS. The files exports are now explicitly in the package.json. The ESM files now have .mjs extension.
BREAKING: The package now has a flat structure, meaning functions are now named node_modules/date-fns/add.mjs, locales are node_modules/date-fns/locale/enUS.mjs, etc.
BREAKING: Now all file content’s exported via named exports instead of export default, which will require change direct imports i.e. const addDays = require(‘date-fns/addDays’) to const { addDays } = require(‘date-fns/addDays’).
BREAKING: TypeScript types are now completely rewritten, check out the d.ts files for more information.
BREAKING: constants now is not exported via the index, so to import one use import { daysInYear } from "date-fns/constants";. It improves compatibility with setups that modularize imports like Next.js.
BREAKING: Functions now don’t check the number of passed arguments, delegating this task to type checkers. The functions are now slimmer because of this.
BREAKING The arguments are not explicitly converted to the target types. Instead, they are passed as is, delegating this task to type checkers.
BREAKING: Functions that accept Interval arguments now do not throw an error if the start is before the end and handle it as a negative interval. If one of the properties in an Invalid Date, these functions also do not throw and handle them as invalid intervals.
areIntervalsOverlapping normalize intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. When comparing intervals with one of the properties being Invalid Date, the function will return false unless the others are valid and equal, given the inclusive option is passed. Otherwise, and when even one of the intervals has both properties invalid, the function will always return false.
getOverlappingDaysInIntervals now normalizes intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. If any of the intervals’ properties is an Invalid Date, the function will always return 0.
isWithinInterval now normalizes intervals before comparison, so { start: a, end: b } is practically equivalent to { start: b, end: a }. If any of the intervals’ properties is an Invalid Date, the function will always return false.
intervalToDuration now returns negative durations for negative intervals. If one or both of the interval properties are invalid, the function will return an empty object.
The eachXOfInterval functions (eachDayOfInterval, eachHourOfInterval, eachMinuteOfInterval, eachMonthOfInterval, eachWeekendOfInterval, eachWeekendOfMonth, eachWeekendOfYear, eachWeekOfInterval, eachYearOfInterval) now return a reversed array if the passed interval’s start is after the end. Invalid properties will result in an empty array. Functions that accept the step option now also allow negative, 0, and NaN values and return reversed results if the step is negative and an empty array otherwise.
BREAKING: intervalToDuration now skips 0 values in the resulting duration, resulting in more compact objects with only relevant properties.
BREAKING: roundToNearestMinutes now returns Invalid Date instead of throwing an error when nearestTo option is less than 1 or more than 30.
BREAKING: IE is no longer supported.
BREAKING: Now all functions use Math.trunc rounding method where rounding is required. The behavior is configurable on a per-function basis.
BREAKING: Undocumented onlyNumeric option was removed from nn and sv locales. If you relied on it, please contact me.
BREAKING: Flow is not supported anymore. If you relied on it, please contact me.
BREAKING: The locales now use regular functions instead of the UTC version, which should not break any code unless you used locales directly.
Dependabot commands
You can trigger Dependabot actions by commenting on this MR
$dependabot recreate will recreate this MR rewriting all the manual changes and resolving conflicts
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.30.0 to 3.0.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/date-fns/date-fns/releases">date-fns's releases</a>.</em></p>
<blockquote>
<h2>v3.0.1</h2>
<h2>Fixed</h2>
<ul>
<li><a href="https://github.com/date-fns/date-fns/pull/3618">Fixed an error</a> in certain environments caused by <code>d.mts</code> files exporting only types.</li>
</ul>
<h2>v3.0.0</h2>
<h2>Changed</h2>
<ul>
<li>
<p><strong>BREAKING</strong>: date-fns is now a dual-package with the support of both ESM and CommonJS. The files exports are now explicitly in the <code>package.json</code>. The ESM files now have <code>.mjs</code> extension.</p>
</li>
<li>
<p><strong>BREAKING</strong>: The package now has a flat structure, meaning functions are now named <code>node_modules/date-fns/add.mjs</code>, locales are <code>node_modules/date-fns/locale/enUS.mjs</code>, etc.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Now all file content’s exported via named exports instead of <code>export default</code>, which will require change direct imports i.e. <code>const addDays = require(‘date-fns/addDays’)</code> to <code>const { addDays } = require(‘date-fns/addDays’)</code>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: TypeScript types are now completely rewritten, check out the <code>d.ts</code> files for more information.</p>
</li>
<li>
<p><strong>BREAKING</strong>: <code>constants</code> now is not exported via the index, so to import one use <code>import { daysInYear } from "date-fns/constants";</code>. It improves compatibility with setups that modularize imports <a href="https://twitter.com/kossnocorp/status/1731181274579325260">like Next.js</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Functions now don’t check the number of passed arguments, delegating this task to type checkers. The functions are now slimmer because of this.</p>
</li>
<li>
<p><strong>BREAKING</strong> The arguments are not explicitly converted to the target types. Instead, they are passed as is, delegating this task to type checkers.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Functions that accept <code>Interval</code> arguments now do not throw an error if the start is before the end and handle it as a negative interval. If one of the properties in an <code>Invalid Date</code>, these functions also do not throw and handle them as invalid intervals.</p>
<ul>
<li>
<p><code>areIntervalsOverlapping</code> normalize intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. When comparing intervals with one of the properties being <code>Invalid Date</code>, the function will return false unless the others are valid and equal, given the <code>inclusive</code> option is passed. Otherwise, and when even one of the intervals has both properties invalid, the function will always return <code>false</code>.</p>
</li>
<li>
<p><code>getOverlappingDaysInIntervals</code> now normalizes intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. If any of the intervals’ properties is an <code>Invalid Date</code>, the function will always return 0.</p>
</li>
<li>
<p><code>isWithinInterval</code> now normalizes intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. If any of the intervals’ properties is an <code>Invalid Date</code>, the function will always return false.</p>
</li>
<li>
<p><code>intervalToDuration</code> now returns negative durations for negative intervals. If one or both of the interval properties are invalid, the function will return an empty object.</p>
</li>
<li>
<p>The eachXOfInterval functions (<code>eachDayOfInterval</code>, <code>eachHourOfInterval</code>, <code>eachMinuteOfInterval</code>, <code>eachMonthOfInterval</code>, <code>eachWeekendOfInterval</code>, <code>eachWeekendOfMonth</code>, <code>eachWeekendOfYear</code>, <code>eachWeekOfInterval</code>, <code>eachYearOfInterval</code>) now return a reversed array if the passed interval’s start is after the end. Invalid properties will result in an empty array. Functions that accept the <code>step</code> option now also allow negative, 0, and NaN values and return reversed results if the step is negative and an empty array otherwise.</p>
</li>
</ul>
</li>
<li>
<p><strong>BREAKING</strong>: <code>intervalToDuration</code> now skips 0 values in the resulting duration, resulting in more compact objects with only relevant properties.</p>
</li>
<li>
<p><strong>BREAKING</strong>: <code>roundToNearestMinutes</code> now returns <code>Invalid Date</code> instead of throwing an error when <code>nearestTo</code> option is less than 1 or more than 30.</p>
</li>
<li>
<p><strong>BREAKING</strong>: IE is no longer supported.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Now all functions use <code>Math.trunc</code> rounding method where rounding is required. The behavior is configurable on a per-function basis.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Undocumented <code>onlyNumeric</code> option was removed from <code>nn</code> and <code>sv</code> locales. If you relied on it, <a href="https://github.com/date-fns/date-fns/blob/HEAD/mailto:koss@nocorp.me">please contact me</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Flow is not supported anymore. If you relied on it, <a href="https://github.com/date-fns/date-fns/blob/HEAD/mailto:koss@nocorp.me">please contact me</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: The locales now use regular functions instead of the UTC version, which should not break any code unless you used locales directly.</p>
</li>
</ul>
<h3>Added</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/date-fns/date-fns/blob/main/CHANGELOG.md">date-fns's changelog</a>.</em></p>
<blockquote>
<h2>v3.0.1 - 2023-12-20</h2>
<h2>Fixed</h2>
<ul>
<li><a href="https://github.com/date-fns/date-fns/pull/3618">Fixed an error</a> in certain environments caused by <code>d.mts</code> files exporting only types.</li>
</ul>
<h2>v3.0.0 - 2023-12-18</h2>
<h2>Changed</h2>
<ul>
<li>
<p><strong>BREAKING</strong>: date-fns is now a dual-package with the support of both ESM and CommonJS. The files exports are now explicitly in the <code>package.json</code>. The ESM files now have <code>.mjs</code> extension.</p>
</li>
<li>
<p><strong>BREAKING</strong>: The package now has a flat structure, meaning functions are now named <code>node_modules/date-fns/add.mjs</code>, locales are <code>node_modules/date-fns/locale/enUS.mjs</code>, etc.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Now all file content’s exported via named exports instead of <code>export default</code>, which will require change direct imports i.e. <code>const addDays = require(‘date-fns/addDays’)</code> to <code>const { addDays } = require(‘date-fns/addDays’)</code>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: TypeScript types are now completely rewritten, check out the <code>d.ts</code> files for more information.</p>
</li>
<li>
<p><strong>BREAKING</strong>: <code>constants</code> now is not exported via the index, so to import one use <code>import { daysInYear } from "date-fns/constants";</code>. It improves compatibility with setups that modularize imports <a href="https://twitter.com/kossnocorp/status/1731181274579325260">like Next.js</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Functions now don’t check the number of passed arguments, delegating this task to type checkers. The functions are now slimmer because of this.</p>
</li>
<li>
<p><strong>BREAKING</strong> The arguments are not explicitly converted to the target types. Instead, they are passed as is, delegating this task to type checkers.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Functions that accept <code>Interval</code> arguments now do not throw an error if the start is before the end and handle it as a negative interval. If one of the properties in an <code>Invalid Date</code>, these functions also do not throw and handle them as invalid intervals.</p>
<ul>
<li>
<p><code>areIntervalsOverlapping</code> normalize intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. When comparing intervals with one of the properties being <code>Invalid Date</code>, the function will return false unless the others are valid and equal, given the <code>inclusive</code> option is passed. Otherwise, and when even one of the intervals has both properties invalid, the function will always return <code>false</code>.</p>
</li>
<li>
<p><code>getOverlappingDaysInIntervals</code> now normalizes intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. If any of the intervals’ properties is an <code>Invalid Date</code>, the function will always return 0.</p>
</li>
<li>
<p><code>isWithinInterval</code> now normalizes intervals before comparison, so <code>{ start: a, end: b }</code> is practically equivalent to <code>{ start: b, end: a }</code>. If any of the intervals’ properties is an <code>Invalid Date</code>, the function will always return false.</p>
</li>
<li>
<p><code>intervalToDuration</code> now returns negative durations for negative intervals. If one or both of the interval properties are invalid, the function will return an empty object.</p>
</li>
<li>
<p>The eachXOfInterval functions (<code>eachDayOfInterval</code>, <code>eachHourOfInterval</code>, <code>eachMinuteOfInterval</code>, <code>eachMonthOfInterval</code>, <code>eachWeekendOfInterval</code>, <code>eachWeekendOfMonth</code>, <code>eachWeekendOfYear</code>, <code>eachWeekOfInterval</code>, <code>eachYearOfInterval</code>) now return a reversed array if the passed interval’s start is after the end. Invalid properties will result in an empty array. Functions that accept the <code>step</code> option now also allow negative, 0, and NaN values and return reversed results if the step is negative and an empty array otherwise.</p>
</li>
</ul>
</li>
<li>
<p><strong>BREAKING</strong>: <code>intervalToDuration</code> now skips 0 values in the resulting duration, resulting in more compact objects with only relevant properties.</p>
</li>
<li>
<p><strong>BREAKING</strong>: <code>roundToNearestMinutes</code> now returns <code>Invalid Date</code> instead of throwing an error when <code>nearestTo</code> option is less than 1 or more than 30.</p>
</li>
<li>
<p><strong>BREAKING</strong>: IE is no longer supported.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Now all functions use <code>Math.trunc</code> rounding method where rounding is required. The behavior is configurable on a per-function basis.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Undocumented <code>onlyNumeric</code> option was removed from <code>nn</code> and <code>sv</code> locales. If you relied on it, <a href="https://github.com/date-fns/date-fns/blob/main/mailto:koss@nocorp.me">please contact me</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: Flow is not supported anymore. If you relied on it, <a href="https://github.com/date-fns/date-fns/blob/main/mailto:koss@nocorp.me">please contact me</a>.</p>
</li>
<li>
<p><strong>BREAKING</strong>: The locales now use regular functions instead of the UTC version, which should not break any code unless you used locales directly.</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/date-fns/date-fns/commit/be27ecff956c0f1185f226f45e520572e2e8b785"><code>be27ecf</code></a> Promote to v3.0.1</li>
<li><a href="https://github.com/date-fns/date-fns/commit/8dc9ab38b0dd98542d36028c2ef6073e31f8851d"><code>8dc9ab3</code></a> Add .d.mts issue example</li>
<li><a href="https://github.com/date-fns/date-fns/commit/cb303e344f5b0eff63edc5aa36d480c1886c0456"><code>cb303e3</code></a> Fix d.mts errors</li>
<li><a href="https://github.com/date-fns/date-fns/commit/95b84c7e4ca73975dbd53b0e51b84fd053de99d7"><code>95b84c7</code></a> Fix change log for v3</li>
<li><a href="https://github.com/date-fns/date-fns/commit/c50c070c01e4f5633f9ecc0868ae994975f7f98f"><code>c50c070</code></a> Promote to v3.0.0</li>
<li><a href="https://github.com/date-fns/date-fns/commit/5de6af43974998f7c00755dd0779665ffad7cc3b"><code>5de6af4</code></a> Fix types</li>
<li><a href="https://github.com/date-fns/date-fns/commit/a44e98a4f8eaf97b971e58c530294b110df57846"><code>a44e98a</code></a> Upgrade size-limit</li>
<li><a href="https://github.com/date-fns/date-fns/commit/fcff3fda269547f7df1daf89fa707b5650591820"><code>fcff3fd</code></a> Upgrade <code>@date-fns/docs</code></li>
<li><a href="https://github.com/date-fns/date-fns/commit/db8ad0d307ae1fd547718eabce6af77c1307f7c6"><code>db8ad0d</code></a> Fix typeParam docs</li>
<li><a href="https://github.com/date-fns/date-fns/commit/59685ab2d56636eb29bbf7bbd7ffd9ad4446517a"><code>59685ab</code></a> Improve the interval docs</li>
<li>Additional commits viewable in <a href="https://github.com/date-fns/date-fns/compare/v2.30.0...v3.0.1">compare view</a></li>
</ul>
</details>
<br />
---
<details>
<summary>Dependabot commands</summary>
<br />
You can trigger Dependabot actions by commenting on this MR
- `$dependabot recreate` will recreate this MR rewriting all the manual changes and resolving conflicts
</details>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bumps date-fns from 2.30.0 to 3.0.1.
Release notes
Sourced from date-fns's releases.
... (truncated)
Changelog
Sourced from date-fns's changelog.
... (truncated)
Commits
be27ecfPromote to v3.0.18dc9ab3Add .d.mts issue examplecb303e3Fix d.mts errors95b84c7Fix change log for v3c50c070Promote to v3.0.05de6af4Fix typesa44e98aUpgrade size-limitfcff3fdUpgrade@date-fns/docsdb8ad0dFix typeParam docs59685abImprove the interval docsDependabot commands
You can trigger Dependabot actions by commenting on this MR
$dependabot recreatewill recreate this MR rewriting all the manual changes and resolving conflictsmentioned in merge request !1550
This merge request has been superseded by !1555+
Pull request closed