UEA-PRODEM

This commit is contained in:
2026-06-10 12:14:46 -03:00
parent f54126b9d8
commit 9947565694
5319 changed files with 148520 additions and 129332 deletions
+27 -18
View File
@@ -1,13 +1,15 @@
# CDN
Starting with v3.6.0, the CDN versions of date-fns are available on [jsDelivr](https://www.jsdelivr.com/package/npm/date-fns) and other CDNs. They expose the date-fns functionality via the `window.dateFns` global variable.
The CDN versions of date-fns are available as the [`@date-fns/cdn`](https://www.jsdelivr.com/package/npm/@date-fns/cdn) package on jsDelivr and other CDNs. They expose the date-fns functionality via the `window.dateFns` global variable.
> ⚠️ The legacy CDN files in the `date-fns` package are deprecated and will be removed in a future version. They remain available for compatibility, but they log a migration notice in the console. Please update your URLs from `date-fns` to `@date-fns/cdn`.
Unlike the npm package, the CDN is transpiled to be compatible with IE11, so it supports a wide variety of legacy browsers and environments.
```html
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/locale/es/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/locale/ru/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/locale/es/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/locale/ru/cdn.min.js"></script>
<script>
dateFns.formatRelative(dateFns.subDays(new Date(), 3), new Date());
//=> "last Friday at 7:26 p.m."
@@ -24,6 +26,13 @@ Unlike the npm package, the CDN is transpiled to be compatible with IE11, so it
</script>
```
Legacy URLs still work for now but should be replaced:
```diff
- https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.min.js
+ https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.min.js
```
The CDN versions are available for the main module, all & individual locales, and the FP submodule.
They come in two flavors: `cdn.js` and `cdn.min.js`. The latter is minified and should be used in production. The former is useful for debugging and development.
@@ -35,14 +44,14 @@ Keep in mind that using the CDN versions in production is suboptimal because the
The main module with all functions bundled:
```
https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.js
https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.min.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/cdn.min.js
```
You can access it via the `dateFns` global variable:
```html
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/cdn.min.js"></script>
<script>
dateFns.addDays(new Date(2014, 1, 11), 10);
//=> Tue Feb 21 2014 00:00:00
@@ -54,14 +63,14 @@ You can access it via the `dateFns` global variable:
The FP submodule with all functions bundled:
```
https://cdn.jsdelivr.net/npm/date-fns@VERSION/fp/cdn.js
https://cdn.jsdelivr.net/npm/date-fns@VERSION/fp/cdn.min.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/fp/cdn.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/fp/cdn.min.js
```
You can access it via the `dateFns.fp` global variable:
```html
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/fp/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/fp/cdn.min.js"></script>
<script>
dateFns.fp.addDays(10, new Date(2014, 1, 11));
//=> Tue Feb 21 2014 00:00:00
@@ -73,15 +82,15 @@ You can access it via the `dateFns.fp` global variable:
All locales bundled:
```
https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/cdn.js
https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/cdn.min.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/cdn.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/cdn.min.js
```
You can access them via the `dateFns.locale` global variable:
```html
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/locale/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/locale/cdn.min.js"></script>
<script>
dateFns.formatRelative(dateFns.subDays(new Date(), 3), new Date(), {
locale: dateFns.locale.es,
@@ -93,15 +102,15 @@ You can access them via the `dateFns.locale` global variable:
The locales are also available as individual files.
```
https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/LOCALE/cdn.js
https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/LOCALE/cdn.min.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/LOCALE/cdn.js
https://cdn.jsdelivr.net/npm/@date-fns/cdn@VERSION/locale/LOCALE/cdn.min.js
```
You can access them via the `dateFns.locale.LOCALE` global variable:
```html
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/locale/es/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/locale/es/cdn.min.js"></script>
<script>
dateFns.formatRelative(dateFns.subDays(new Date(), 3), new Date(), {
locale: dateFns.locale.es,
+2 -4
View File
@@ -1,5 +1,3 @@
/* eslint-disable */
/** @type {import('@date-fns/docs').DateFnsDocs.Config} */
export const config = {
package: "..",
@@ -52,7 +50,7 @@ export const config = {
category: "General",
title: "Contributing",
summary: "Contribution manual",
path: "../CONTRIBUTING.md",
path: "../../../CONTRIBUTING.md",
},
{
type: "markdown",
@@ -60,7 +58,7 @@ export const config = {
category: "General",
title: "Security policy",
summary: "Security policy",
path: "../SECURITY.md",
path: "../../../SECURITY.md",
},
{
type: "markdown",
+1 -4
View File
@@ -3,13 +3,11 @@
## Table of Contents
- [Adding a new locale](#adding-a-new-locale)
- [Choosing a directory name for a locale](#choosing-a-directory-name-for-a-locale)
- [index.js](#index.js)
- [localize](#localize)
- [localize.ordinalNumber](#localize.ordinalnumber)
- [localize.era and using buildLocalizeFn function](#localize.era-and-using-buildlocalizefn-function)
@@ -25,7 +23,6 @@
- [localize.dayPeriod](#localize.dayperiod)
- [formatLong](#formatlong)
- [formatLong.dateFormats](#formatlong.dateformats)
- [formatLong.timeFormats](#formatlong.timeformats)
@@ -1016,7 +1013,7 @@ Your best guess is to copy `formatDistance` property from another locale and cha
To test locales we use snapshots. See [`en-US` snapshot](https://github.com/date-fns/date-fns/blob/master/src/locale/en-US/snapshot.md) for an example.
To generate snapshots, run `npm run locale-snapshots`. The snapshot for the locale
To generate snapshots, run `pnpm run locale-snapshots`. The snapshot for the locale
you're working on will appear in the root locale directory (e.g. `src/locales/ru/snapshot.md`).
Once you are done with the locale, generate the snapshot and review the output values.
+1 -1
View File
@@ -2,7 +2,7 @@
1. First, make sure that the library is built by running `./scripts/build/build.sh` and committing and pushing any change you would have.
2. Then add the changelog entry generated by `npx tsx scripts/release/buildChangelog.ts` to (CHANGELOG.md)[../CHANGELOG.md]. Make sure that the output is valid Markdown and fix if there're any errors. Commit and push the file.
2. Then add the changelog entry generated by `node scripts/release/buildChangelog.ts` to (CHANGELOG.md)[../CHANGELOG.md]. Make sure that the output is valid Markdown and fix if there're any errors. Commit and push the file.
3. Using the version that the changelog script generated, run the command:
+23
View File
@@ -93,6 +93,29 @@ differenceInBusinessDays(laterDate, earlierDate, {
In the example, we forced `differenceInBusinessDays` to use the Los Angeles time zone.
## Transposing date values
Sometimes, you want to transpose date values from a date instance to another time zone or vice versa. For that, you would use the `transpose` function:
```ts
import { transpose } from "date-fns";
import { tz } from "@date-fns/tz";
// Singapore is the system time zone:
const sgDate = new Date(2024, 8 /* Sep */, 7, 6, 5, 4);
//=> 'Wed Sep 07 2024 06:05:04 GMT+0800 (Singapore Standard Time)'
// Transpose the date to Los Angeles time zone:
const laDate = transpose(sgDate, tz("America/Los_Angeles"));
//=> 'Wed Sep 07 2024 06:05:04 GMT-0700 (Pacific Daylight Time)'
// Transpose back to local time zone using Date:
const systemDate = transpose(laDate, Date);
//=> 'Wed Sep 07 2024 06:05:04 GMT+0800 (Singapore Standard Time)'
```
This is the `date-fns-tz`'s `fromZonedTime` and `toZonedTime` equivalent.
## Further reading
Read more about the time zone packages visiting their READMEs: