@edifice.io/react 2.3.0-develop.20250905141726 → 2.3.1-develop-b2school-actualites.20250911101750
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,10 +6,23 @@ export type NumberDate = number;
|
|
|
6
6
|
/** Date formats we are going to deal with. */
|
|
7
7
|
export type CoreDate = IsoDate | MongoDate | NumberDate;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Custom React hook for date parsing, formatting, and localization.
|
|
10
|
+
*
|
|
11
|
+
* Provides utility functions to:
|
|
12
|
+
* - Parse various date formats and timestamps into Dayjs objects, respecting the current language.
|
|
13
|
+
* - Format dates in user-friendly ways, including "time ago", "yesterday", and localized date strings.
|
|
14
|
+
* - Compute elapsed durations from a given date to now.
|
|
15
|
+
*
|
|
16
|
+
* @returns An object containing:
|
|
17
|
+
* - `fromNow(date: CoreDate | NumberDate): string` — Returns a human-readable elapsed duration from the given date to now.
|
|
18
|
+
* - `formatDate(date: CoreDate, format?: 'short' | 'long' | 'abbr' | string): string` — Formats a date according to the specified format and current language.
|
|
19
|
+
* - `formatTimeAgo(date: CoreDate | NumberDate): string` — Returns a localized string representing how long ago the date was, with special handling for today, yesterday, and recent dates.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - Uses the current language from the Edifice client context for localization.
|
|
10
23
|
*/
|
|
11
24
|
export default function useDate(): {
|
|
12
|
-
fromNow: (date: CoreDate
|
|
25
|
+
fromNow: (date: CoreDate) => string;
|
|
13
26
|
formatDate: (date: CoreDate, format?: string) => string;
|
|
14
|
-
formatTimeAgo: (date: CoreDate
|
|
27
|
+
formatTimeAgo: (date: CoreDate) => string;
|
|
15
28
|
};
|
|
@@ -8,8 +8,8 @@ import "dayjs/locale/es.js";
|
|
|
8
8
|
import "dayjs/locale/fr.js";
|
|
9
9
|
import "dayjs/locale/it.js";
|
|
10
10
|
import "dayjs/locale/pt.js";
|
|
11
|
-
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
12
11
|
import { useTranslation } from "react-i18next";
|
|
12
|
+
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
13
13
|
dayjs.extend(relativeTime);
|
|
14
14
|
dayjs.extend(customParseFormat);
|
|
15
15
|
dayjs.extend(localizedFormat);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1-develop-b2school-actualites.20250911101750",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -130,9 +130,9 @@
|
|
|
130
130
|
"react-slugify": "^3.0.3",
|
|
131
131
|
"swiper": "^10.1.0",
|
|
132
132
|
"ua-parser-js": "^1.0.36",
|
|
133
|
-
"@edifice.io/bootstrap": "2.3.
|
|
134
|
-
"@edifice.io/tiptap-extensions": "2.3.
|
|
135
|
-
"@edifice.io/utilities": "2.3.
|
|
133
|
+
"@edifice.io/bootstrap": "2.3.1-develop-b2school-actualites.20250911101750",
|
|
134
|
+
"@edifice.io/tiptap-extensions": "2.3.1-develop-b2school-actualites.20250911101750",
|
|
135
|
+
"@edifice.io/utilities": "2.3.1-develop-b2school-actualites.20250911101750"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -163,8 +163,8 @@
|
|
|
163
163
|
"vite": "^5.4.11",
|
|
164
164
|
"vite-plugin-dts": "^4.1.0",
|
|
165
165
|
"vite-tsconfig-paths": "^5.0.1",
|
|
166
|
-
"@edifice.io/client": "2.3.
|
|
167
|
-
"@edifice.io/config": "2.3.
|
|
166
|
+
"@edifice.io/client": "2.3.1-develop-b2school-actualites.20250911101750",
|
|
167
|
+
"@edifice.io/config": "2.3.1-develop-b2school-actualites.20250911101750"
|
|
168
168
|
},
|
|
169
169
|
"peerDependencies": {
|
|
170
170
|
"@react-spring/web": "^9.7.5",
|