Skip to content

Commit

Permalink
Bump date-fns from 3.6.0 to 4.1.0 (#133)
Browse files Browse the repository at this point in the history
Bumps [date-fns](https://github.com/date-fns/date-fns) from 3.6.0 to
4.1.0.
<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>v4.1.0</h2>
<p>This release adds time zone support to format functions (that I
somehow missed when working on the feature) and fixes a few bugs.</p>
<p>Make sure also upgrade <code>TZDate</code> to v1.0.2 as it <a
href="https://github.com/date-fns/tz/blob/main/CHANGELOG.md#v102---2024-09-14">includes
a bunch of critical bug fixes</a>.</p>
<h3>Fixed</h3>
<ul>
<li>Fixed internal <code>constructFrom</code> throwing an exception on
<code>null</code> arguments. While <code>null</code> isn't allowed, the
functions should rather return <code>Invalid Date</code> or
<code>NaN</code> in such cases. See <a
href="https://redirect.github.com/date-fns/date-fns/issues/3885">#3885</a>.</li>
</ul>
<h3>Added</h3>
<ul>
<li>Added missing time zone support to <code>format</code>,
<code>formatISO</code>, <code>formatISO9075</code>,
<code>formatRelative</code> and <code>formatRFC3339</code>. See <a
href="https://redirect.github.com/date-fns/date-fns/issues/3886">#3886</a>.</li>
</ul>
<h2>v4.0.0</h2>
<p>I have great news! First, ten years after its release, date-fns
finally gets first-class time zone support.</p>
<p>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.</p>
<p><a href="https://blog.date-fns.org/v40-with-time-zone-support/">Read
more about the release in the announcement blog post</a>.</p>
<p>- <a href="https://twitter.com/kossnocorp"><code>Sasha
@​kossnocorp</code></a></p>
<h3>Added</h3>
<ul>
<li>
<p>Added time zones support via <a
href="https://github.com/date-fns/tz"><code>@date-fns/tz</code></a>'s
<code>TZDate</code> class and <code>tz</code> helper function. See its
<a href="https://github.com/date-fns/tz">README</a> for the details
about the API.</p>
</li>
<li>
<p>All relevant functions now accept the context <code>in</code> 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:</p>
<pre lang="ts"><code>import { addDays, startOfDay } from
&quot;date-fns&quot;;
import { tz } from &quot;@date-fns/tz&quot;;
<p>startOfDay(addDays(Date.now(), 5, { in:
tz(&quot;Asia/Singapore&quot;) }));<br />
//=&gt; &quot;2024-09-16T00:00:00.000+08:00&quot;<br />
</code></pre></p>
<p>In the example, <code>addDays</code> will get the current date and
time in Singapore and add 5 days to it. <code>startOfDay</code> will
inherit the date type and return the start of the day in Singapore.</p>
</li>
</ul>
<h3>Changed</h3>
<ul>
<li>
<p>The function arguments, as well as <code>Interval</code>'s
<code>start</code> and <code>end</code>, now can be of different types,
allowing you to mix <code>UTCDate</code>, <code>TZDate</code>,
<code>Date</code>, and other extensions, as well as primitives (strings
and numbers).</p>
<p>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
<code>in</code> option or the first encountered argument object type.
The <code>Interval</code>'s <code>start</code> and <code>end</code> will
be considered separately, starting from <code>start</code>.</p>
<p>In the given example, the result will be in the <code>TZDate</code>
as the first argument is a number, and the <code>start</code> takes
precedence over the <code>end</code>.</p>
<pre lang="ts"><code>clamp(Date.now(), {
  start: new TZDate(start, &quot;Asia/Singapore&quot;),
  end: new UTCDate(),
</code></pre>
</li>
</ul>
<!-- 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>v4.1.0 - 2024-09-17</h2>
<p>This release adds time zone support to format functions (that I
somehow missed when working on the feature) and fixes a few bugs.</p>
<p>Make sure also upgrade <code>TZDate</code> to v1.0.2 as it <a
href="https://github.com/date-fns/tz/blob/main/CHANGELOG.md#v102---2024-09-14">includes
a bunch of critical bug fixes</a>.</p>
<h3>Fixed</h3>
<ul>
<li>Fixed internal <code>constructFrom</code> throwing an exception on
<code>null</code> arguments. While <code>null</code> isn't allowed, the
functions should rather return <code>Invalid Date</code> or
<code>NaN</code> in such cases. See <a
href="https://redirect.github.com/date-fns/date-fns/issues/3885">#3885</a>.</li>
</ul>
<h3>Added</h3>
<ul>
<li>Added missing time zone support to <code>format</code>,
<code>formatISO</code>, <code>formatISO9075</code>,
<code>formatRelative</code> and <code>formatRFC3339</code>. See <a
href="https://redirect.github.com/date-fns/date-fns/issues/3886">#3886</a>.</li>
</ul>
<h2>v4.0.0 - 2024-09-16</h2>
<p>I have great news! First, ten years after its release, date-fns
finally gets first-class time zone support.</p>
<p>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.</p>
<p><a href="https://blog.date-fns.org/v40-with-time-zone-support/">Read
more about the release in the announcement blog post</a>.</p>
<p>- <a href="https://twitter.com/kossnocorp"><code>Sasha
@​kossnocorp</code></a></p>
<h3>Added</h3>
<ul>
<li>
<p>Added time zones support via <a
href="https://github.com/date-fns/tz"><code>@date-fns/tz</code></a>'s
<code>TZDate</code> class and <code>tz</code> helper function. See its
<a href="https://github.com/date-fns/tz">README</a> for the details
about the API.</p>
</li>
<li>
<p>All relevant functions now accept the context <code>in</code> 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:</p>
<pre lang="ts"><code>import { addDays, startOfDay } from
&quot;date-fns&quot;;
import { tz } from &quot;@date-fns/tz&quot;;
<p>startOfDay(addDays(Date.now(), 5, { in:
tz(&quot;Asia/Singapore&quot;) }));<br />
//=&gt; &quot;2024-09-16T00:00:00.000+08:00&quot;<br />
</code></pre></p>
<p>In the example, <code>addDays</code> will get the current date and
time in Singapore and add 5 days to it. <code>startOfDay</code> will
inherit the date type and return the start of the day in Singapore.</p>
</li>
</ul>
<h3>Changed</h3>
<ul>
<li>
<p>The function arguments, as well as <code>Interval</code>'s
<code>start</code> and <code>end</code>, now can be of different types,
allowing you to mix <code>UTCDate</code>, <code>TZDate</code>,
<code>Date</code>, and other extensions, as well as primitives (strings
and numbers).</p>
<p>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
<code>in</code> option or the first encountered argument object type.
The <code>Interval</code>'s <code>start</code> and <code>end</code> will
be considered separately, starting from <code>start</code>.</p>
<p>In the given example, the result will be in the <code>TZDate</code>
as the first argument is a number, and the <code>start</code> takes
precedence over the <code>end</code>.</p>
<pre lang="ts"><code>clamp(Date.now(), {
</code></pre>
</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/313b902b9a72c64501074db9bc2b9897d2db5140"><code>313b902</code></a>
Fix v4.1.0 change log entry</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/26cd336cc239cf543337ac33f3ae5367d3292469"><code>26cd336</code></a>
Promote to v4.1.0</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/97b53b97e993c6d6aadcdc31b9042397a4c00f03"><code>97b53b9</code></a>
Cover time zone edge cases</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/59b756385a205d554c9799fa7b28a0c52ddc0281"><code>59b7563</code></a>
Add missing time zone support to format, formatISO, formatISO9075,
formatRela...</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/0121164052a65667ef31c0285a48afb8064dfe8b"><code>0121164</code></a>
Prevent constructFrom from throwing an error on null</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/bd87ef5848ebb93c5b3e2f6fc2f7e10b4e72041a"><code>bd87ef5</code></a>
Update <code>@​date-fns/docs</code></li>
<li><a
href="https://github.com/date-fns/date-fns/commit/99b4e671d7c9ac21ac3109261d085fe861cec691"><code>99b4e67</code></a>
Prepare v4.0</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/8df1706c6dea84330974df2834ca1c4d379ea44d"><code>8df1706</code></a>
Rewrite the time zones doc</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/e3519776c57034b0e419a39d4f922b773ea8b688"><code>e351977</code></a>
Promote to v4.0.0-beta.1</li>
<li><a
href="https://github.com/date-fns/date-fns/commit/8523656e296102a125d2ff36d4afcf9f6044d855"><code>8523656</code></a>
Fix scripts/test/types.sh</li>
<li>Additional commits viewable in <a
href="https://github.com/date-fns/date-fns/compare/v3.6.0...v4.1.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=date-fns&package-manager=npm_and_yarn&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nat Welch <[email protected]>
  • Loading branch information
dependabot[bot] and icco authored Sep 19, 2024
1 parent 57781b7 commit c9243ba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"author": "Nat Welch <[email protected]>",
"homepage": "https://natwelch.com",
"dependencies": {
"@date-fns/tz": "^1.0.2",
"@heroicons/react": "^2.0.18",
"@mdx-js/react": "^3.0.0",
"@next/env": "^14.0.0",
"@root/walk": "^1.1.0",
"contentlayer2": "^0.5.0",
"daisyui": "^4.7.3",
"date-fns": "^3.0.0",
"date-fns": "^4.1.0",
"gray-matter": "^4.0.3",
"isomorphic-unfetch": "^4.0.0",
"lodash": "^4.17.21",
"luxon": "^3.0.0",
"next": "^14.0.0",
"next-contentlayer2": "^0.5.0",
"next-secure-headers": "^2.1.0",
Expand All @@ -48,7 +48,6 @@
"@babel/core": "^7.0.0",
"@tailwindcss/typography": "^0.5.10",
"@types/lodash": "^4.14.178",
"@types/luxon": "^3.0.0",
"@types/mdx": "^2.0.2",
"@types/react": "^18.2.12",
"@types/react-dom": "^18.0.4",
Expand Down
2 changes: 1 addition & 1 deletion public/sitemap-0.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://natwelch.com/wiki</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com/wiki/about</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com/wiki/books</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com/wiki/books/locative.garden</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
Expand Down Expand Up @@ -36,5 +37,4 @@
<url><loc>https://natwelch.com/wiki/talks</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com/wiki/writing</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://natwelch.com/wiki</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>
</urlset>
17 changes: 8 additions & 9 deletions src/components/Age.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { DateTime } from "luxon";
import { TZDate } from "@date-fns/tz";
import { differenceInCalendarYears, formatISO } from "date-fns";

export default function Age() {
const birth = DateTime.fromObject(
{ year: 1988, month: 2, day: 22, hour: 17 },
{ zone: "America/Los_Angeles" }
);
const now = DateTime.now();
const diff = now.diff(birth, "years", { conversionAccuracy: "longterm" });
const birth = new TZDate(1988, 2, 22, 17, "America/Los_Angeles");

const now = Date.now();
const diff = differenceInCalendarYears(now, birth);
if (birth && now && diff) {
const birthString = birth.toISO() ?? "";
return <time dateTime={birthString}>{diff.toHuman()} ago</time>;
const birthString = formatISO(birth);
return <time dateTime={birthString}>{diff} ago</time>;
}

return <></>;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./rc.css";

import { TZDate } from "@date-fns/tz";
import {
CodeBracketIcon,
DocumentCheckIcon,
Expand All @@ -14,8 +15,8 @@ const Footer = () => {
<footer className="footer items-center p-4">
<aside className="items-center grid-flow-col">
<p>
&copy; 2011 - {format(new Date(), "yyyy")} Nat Welch. All rights
reserved.
&copy; 2011 - {format(TZDate.tz("America/New_York"), "yyyy")} Nat
Welch. All rights reserved.
</p>
</aside>
<nav className="grid-flow-col gap-4 md:place-self-center md:justify-self-end">
Expand Down
23 changes: 9 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@
resolved "https://registry.yarnpkg.com/@corex/deepmerge/-/deepmerge-4.0.43.tgz#9bd42559ebb41cc5a7fb7cfeea5f231c20977dca"
integrity sha512-N8uEMrMPL0cu/bdboEWpQYb/0i2K5Qn8eCsxzOmxSggJbbQte7ljMRoXm917AbntqTGOzdTu+vP3KOOzoC70HQ==

"@date-fns/tz@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@date-fns/tz/-/tz-1.0.2.tgz#17c72fbded3f9d0440dec82832f3f505e2e7674b"
integrity sha512-iKxj0kXMy7Qe6vjK+flz33cpy2j0dnTKT5i54p3fFlB411J47aSs6HBg7LOO5X9LjDi2iNlctD9rFn738ySOGQ==

"@effect-ts/core@^0.60.5":
version "0.60.5"
resolved "https://registry.yarnpkg.com/@effect-ts/core/-/core-0.60.5.tgz#df79049e1be4a576ab6b45abbe92c831bda62361"
Expand Down Expand Up @@ -1101,11 +1106,6 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.7.tgz#2f776bcb53adc9e13b2c0dfd493dfcbd7de43612"
integrity sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==

"@types/luxon@^3.0.0":
version "3.4.2"
resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.4.2.tgz#e4fc7214a420173cea47739c33cdf10874694db7"
integrity sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==

"@types/mdast@^3.0.0":
version "3.0.15"
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5"
Expand Down Expand Up @@ -2013,10 +2013,10 @@ data-view-byte-offset@^1.0.0:
es-errors "^1.3.0"
is-data-view "^1.0.1"

date-fns@^3.0.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf"
integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==
date-fns@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-4.1.0.tgz#64b3d83fff5aa80438f5b1a633c2e83b8a1c2d14"
integrity sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==

debug@^3.2.7:
version "3.2.7"
Expand Down Expand Up @@ -3896,11 +3896,6 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

luxon@^3.0.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.5.0.tgz#6b6f65c5cd1d61d1fd19dbf07ee87a50bf4b8e20"
integrity sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==

markdown-extensions@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/markdown-extensions/-/markdown-extensions-2.0.0.tgz#34bebc83e9938cae16e0e017e4a9814a8330d3c4"
Expand Down

0 comments on commit c9243ba

Please sign in to comment.