Skip to content

Commit

Permalink
chore: bump up date-fns version to v4 (#8405)
Browse files Browse the repository at this point in the history
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [date-fns](https://redirect.github.com/date-fns/date-fns) | [`^3.6.0` -> `^4.0.0`](https://renovatebot.com/diffs/npm/date-fns/3.6.0/4.1.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/date-fns/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/date-fns/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/date-fns/3.6.0/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/date-fns/3.6.0/4.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>date-fns/date-fns (date-fns)</summary>

### [`v4.1.0`](https://redirect.github.com/date-fns/date-fns/blob/HEAD/CHANGELOG.md#v410---2024-09-17)

[Compare Source](https://redirect.github.com/date-fns/date-fns/compare/v4.0.0...v4.1.0)

This release adds time zone support to format functions (that I somehow missed when working on the feature) and fixes a few bugs.

Make sure also upgrade `TZDate` to v1.0.2 as it [includes a bunch of critical bug fixes](https://redirect.github.com/date-fns/tz/blob/main/CHANGELOG.md#v102---2024-09-14).

##### Fixed

-   Fixed internal `constructFrom` throwing an exception on `null` arguments. While `null` isn't allowed, the functions should rather return `Invalid Date` or `NaN` in such cases. See [#&#8203;3885](https://redirect.github.com/date-fns/date-fns/issues/3885).

##### Added

-   Added missing time zone support to `format`, `formatISO`, `formatISO9075`, `formatRelative` and `formatRFC3339`. See [#&#8203;3886](https://redirect.github.com/date-fns/date-fns/issues/3886).

### [`v4.0.0`](https://redirect.github.com/date-fns/date-fns/blob/HEAD/CHANGELOG.md#v400---2024-09-16)

[Compare Source](https://redirect.github.com/date-fns/date-fns/compare/v3.6.0...v4.0.0)

I have great news! First, ten years after its release, date-fns finally gets first-class time zone support.

Another great news is that there aren't many breaking changes in this release. All of them are type-related and will affect only those explicitly using internal date-fns types. Finally, it has been less than a year since the last major release, which is an improvement over the previous four years between v2 and v3. I plan on keeping the pace and minimizing breaking changes moving forward.

[Read more about the release in the announcement blog post](https://blog.date-fns.org/v40-with-time-zone-support/).

\- [Sasha @&#8203;kossnocorp](https://twitter.com/kossnocorp)

##### Added

-   Added time zones support via [`@date-fns/tz`](https://redirect.github.com/date-fns/tz)'s `TZDate` class and `tz` helper function. See its [README](https://redirect.github.com/date-fns/tz) for the details about the API.

-   All relevant functions now accept the context `in` option, which allows to specify the time zone to make the calculations in. If the function also returns a date, it will be in the specified time zone:

    ```ts
    import { addDays, startOfDay } from "date-fns";
    import { tz } from "@&#8203;date-fns/tz";

    startOfDay(addDays(Date.now(), 5, { in: tz("Asia/Singapore") }));
    //=> "2024-09-16T00:00:00.000+08:00"
    ```

    In the example, `addDays` will get the current date and time in Singapore and add 5 days to it. `startOfDay` will inherit the date type and return the start of the day in Singapore.

##### Changed

-   The function arguments, as well as `Interval`'s `start` and `end`, now can be of different types, allowing you to mix `UTCDate`, `TZDate`, `Date`, and other extensions, as well as primitives (strings and numbers).

    The functions will normalize these values, make calculations, and return the result in the same type, preventing any bugs caused by the discrepancy. If passed, the type will be inferred from the context `in` option or the first encountered argument object type. The `Interval`'s `start` and `end` will be considered separately, starting from `start`.

    In the given example, the result will be in the `TZDate` as the first argument is a number, and the `start` takes precedence over the `end`.

    ```ts
    clamp(Date.now(), {
      start: new TZDate(start, "Asia/Singapore"),
      end: new UTCDate(),
    });
    //=> TZDate
    ```

-   **BREAKING**: This release contains a bunch of types changes that should not affect the library's expected usage. The changes are primarily internal and nuanced, so rather than listing them here, I recommend you running the type checker after the upgrade. If there are unfixable problems, please [open an issue](https://redirect.github.com/date-fns/date-fns/issues/new).

-   **BREAKING**: The package now is ESM-first. The CommonJS is still support and It should not affect most users, but it might break in certains environments. If you encounter any issues, please [report them](https://redirect.github.com/date-fns/date-fns/issues/new).

##### Fixed

-   Fixed CDN build compatibility with jQuery and other tools that expose `$` by properly wrapping the code in an IIFE.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/blocksuite).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6W119-->
  • Loading branch information
renovate[bot] committed Sep 19, 2024
1 parent b1e7078 commit 204c84a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/affine/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@lottiefiles/dotlottie-wc": "^0.2.16",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.0.8",
"date-fns": "^3.6.0",
"date-fns": "^4.0.0",
"katex": "^0.16.11",
"lit": "^3.2.0",
"shiki": "^1.12.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/affine/data-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.0.8",
"date-fns": "^3.6.0",
"date-fns": "^4.0.0",
"lit": "^3.2.0",
"sortablejs": "^1.15.2",
"zod": "^3.23.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/mdast": "^4.0.4",
"@types/sortablejs": "^1.15.8",
"collapse-white-space": "^2.1.0",
"date-fns": "^3.6.0",
"date-fns": "^4.0.0",
"dompurify": "^3.1.6",
"fflate": "^0.8.2",
"file-type": "^19.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@blocksuite/blocks": "workspace:*",
"@blocksuite/presets": "workspace:*",
"@blocksuite/store": "workspace:*",
"date-fns": "^3.6.0",
"date-fns": "^4.0.0",
"markdown-it-container": "^4.0.0",
"vitepress-plugin-sandpack": "^1.1.4"
}
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ __metadata:
"@preact/signals-core": "npm:^1.8.0"
"@toeverything/theme": "npm:^1.0.8"
"@types/katex": "npm:^0.16.7"
date-fns: "npm:^3.6.0"
date-fns: "npm:^4.0.0"
katex: "npm:^0.16.11"
lit: "npm:^3.2.0"
shiki: "npm:^1.12.0"
Expand Down Expand Up @@ -1868,7 +1868,7 @@ __metadata:
"@types/mdast": "npm:^4.0.4"
"@types/sortablejs": "npm:^1.15.8"
collapse-white-space: "npm:^2.1.0"
date-fns: "npm:^3.6.0"
date-fns: "npm:^4.0.0"
dompurify: "npm:^3.1.6"
fflate: "npm:^0.8.2"
file-type: "npm:^19.4.1"
Expand Down Expand Up @@ -1915,7 +1915,7 @@ __metadata:
"@preact/signals-core": "npm:^1.8.0"
"@toeverything/theme": "npm:^1.0.8"
"@types/sortablejs": "npm:^1.15.8"
date-fns: "npm:^3.6.0"
date-fns: "npm:^4.0.0"
lit: "npm:^3.2.0"
sortablejs: "npm:^1.15.2"
zod: "npm:^3.23.8"
Expand All @@ -1929,7 +1929,7 @@ __metadata:
"@blocksuite/blocks": "workspace:*"
"@blocksuite/presets": "workspace:*"
"@blocksuite/store": "workspace:*"
date-fns: "npm:^3.6.0"
date-fns: "npm:^4.0.0"
markdown-it-container: "npm:^4.0.0"
typedoc: "npm:^0.26.6"
typedoc-plugin-markdown: "npm:4.2.7"
Expand Down Expand Up @@ -7096,10 +7096,10 @@ __metadata:
languageName: node
linkType: hard

"date-fns@npm:^3.6.0":
version: 3.6.0
resolution: "date-fns@npm:3.6.0"
checksum: 10/cac35c58926a3b5d577082ff2b253612ec1c79eb6754fddef46b6a8e826501ea2cb346ecbd211205f1ba382ddd1f9d8c3f00bf433ad63cc3063454d294e3a6b8
"date-fns@npm:^4.0.0":
version: 4.1.0
resolution: "date-fns@npm:4.1.0"
checksum: 10/d5f6e9de5bbc52310f786099e18609289ed5e30af60a71e0646784c8185ddd1d0eebcf7c96b7faaaefc4a8366f3a3a4244d099b6d0866ee2bec80d1361e64342
languageName: node
linkType: hard

Expand Down

0 comments on commit 204c84a

Please sign in to comment.