@paroicms/server 1.96.0 → 1.97.0
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.
- package/dist/rendered-site/helpers/format-date.helper.d.ts +1 -8
- package/dist/rendered-site/helpers/format-date.helper.js +53 -18
- package/dist/rendered-site/helpers/format-date.helper.js.map +1 -1
- package/dist/rendered-site/liquidjs-filters/format-date.js +2 -0
- package/dist/rendered-site/liquidjs-filters/format-date.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import "dayjs/locale/de.js";
|
|
3
|
-
import "dayjs/locale/en.js";
|
|
4
|
-
import "dayjs/locale/es.js";
|
|
5
|
-
import "dayjs/locale/fr.js";
|
|
6
|
-
import "dayjs/locale/it.js";
|
|
7
|
-
import "dayjs/locale/pt.js";
|
|
8
|
-
export declare function formatDate(date: Parameters<typeof dayjs>[0], language: string, format?: string): string;
|
|
1
|
+
export declare function formatDate(date: string | Date | number, language: string, formatType?: string): string;
|
|
@@ -1,28 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import "dayjs/locale/pt.js";
|
|
8
|
-
import localizedFormat from "dayjs/plugin/localizedFormat.js";
|
|
9
|
-
dayjs.extend(localizedFormat);
|
|
10
|
-
export function formatDate(date, language, format = "short") {
|
|
11
|
-
const dayjsDate = dayjs(date);
|
|
1
|
+
import { format, parseISO } from "date-fns";
|
|
2
|
+
import { de, enUS, es, fr, it, pt } from "date-fns/locale";
|
|
3
|
+
const locales = { de, en: enUS, es, fr, it, pt };
|
|
4
|
+
export function formatDate(date, language, formatType = "short") {
|
|
5
|
+
const dateObj = typeof date === "string" ? parseISO(date) : new Date(date);
|
|
6
|
+
const locale = locales[language] || locales.en;
|
|
12
7
|
let formattedDate;
|
|
13
|
-
if (
|
|
14
|
-
|
|
8
|
+
if (formatType === "long") {
|
|
9
|
+
if (language === "fr") {
|
|
10
|
+
formattedDate = format(dateObj, "d MMMM yyyy", { locale });
|
|
11
|
+
}
|
|
12
|
+
else if (language === "de") {
|
|
13
|
+
formattedDate = format(dateObj, "d. MMMM yyyy", { locale });
|
|
14
|
+
}
|
|
15
|
+
else if (language === "es") {
|
|
16
|
+
formattedDate = format(dateObj, "d 'de' MMMM 'de' yyyy", { locale });
|
|
17
|
+
}
|
|
18
|
+
else if (language === "it") {
|
|
19
|
+
formattedDate = format(dateObj, "d MMMM yyyy", { locale });
|
|
20
|
+
}
|
|
21
|
+
else if (language === "pt") {
|
|
22
|
+
formattedDate = format(dateObj, "d 'de' MMMM 'de' yyyy", { locale });
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
formattedDate = format(dateObj, "MMMM d, yyyy", { locale });
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
|
-
else if (
|
|
28
|
+
else if (formatType === "long2") {
|
|
17
29
|
if (language === "fr") {
|
|
18
|
-
formattedDate =
|
|
30
|
+
formattedDate = format(dateObj, "EEEE d MMMM yyyy", { locale });
|
|
31
|
+
}
|
|
32
|
+
else if (language === "de") {
|
|
33
|
+
formattedDate = format(dateObj, "EEEE, d. MMMM yyyy", { locale });
|
|
34
|
+
}
|
|
35
|
+
else if (language === "es") {
|
|
36
|
+
formattedDate = format(dateObj, "EEEE, d 'de' MMMM 'de' yyyy", { locale });
|
|
37
|
+
}
|
|
38
|
+
else if (language === "it") {
|
|
39
|
+
formattedDate = format(dateObj, "EEEE, d MMMM yyyy", { locale });
|
|
40
|
+
}
|
|
41
|
+
else if (language === "pt") {
|
|
42
|
+
formattedDate = format(dateObj, "EEEE, d 'de' MMMM 'de' yyyy", { locale });
|
|
19
43
|
}
|
|
20
44
|
else {
|
|
21
|
-
formattedDate =
|
|
45
|
+
formattedDate = format(dateObj, "EEEE, MMMM d, yyyy", { locale });
|
|
22
46
|
}
|
|
23
47
|
}
|
|
24
|
-
else if (
|
|
25
|
-
|
|
48
|
+
else if (formatType === "short") {
|
|
49
|
+
if (language === "fr" || language === "it") {
|
|
50
|
+
formattedDate = format(dateObj, "d/M/yyyy", { locale });
|
|
51
|
+
}
|
|
52
|
+
else if (language === "de") {
|
|
53
|
+
formattedDate = format(dateObj, "d.M.yyyy", { locale });
|
|
54
|
+
}
|
|
55
|
+
else if (language === "es" || language === "pt") {
|
|
56
|
+
formattedDate = format(dateObj, "d/M/yyyy", { locale });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
formattedDate = format(dateObj, "M/d/yy", { locale });
|
|
60
|
+
}
|
|
26
61
|
}
|
|
27
62
|
else {
|
|
28
63
|
throw new Error("unknown format");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date.helper.js","sourceRoot":"","sources":["../../../src/rendered-site/helpers/format-date.helper.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"format-date.helper.js","sourceRoot":"","sources":["../../../src/rendered-site/helpers/format-date.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,OAAO,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AAEjD,MAAM,UAAU,UAAU,CACxB,IAA4B,EAC5B,QAAgB,EAChB,UAAU,GAAG,OAAO;IAEpB,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,OAAO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H,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { formatDate } from "../helpers/format-date.helper.js";
|
|
|
2
2
|
export function formatDateLiquidFilter(value, { renderingContext, args }) {
|
|
3
3
|
const format = typeof args[0] === "string" ? args[0] : undefined;
|
|
4
4
|
const dt = typeof value === "string" || value instanceof Date ? value : undefined;
|
|
5
|
+
if (!dt)
|
|
6
|
+
return "";
|
|
5
7
|
return formatDate(dt, renderingContext.language, format);
|
|
6
8
|
}
|
|
7
9
|
//# sourceMappingURL=format-date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date.js","sourceRoot":"","sources":["../../../src/rendered-site/liquidjs-filters/format-date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,MAAM,UAAU,sBAAsB,CACpC,KAAc,EACd,EAAE,gBAAgB,EAAE,IAAI,EAA2D;IAEnF,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,MAAM,EAAE,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,OAAO,UAAU,CAAC,EAAE,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
1
|
+
{"version":3,"file":"format-date.js","sourceRoot":"","sources":["../../../src/rendered-site/liquidjs-filters/format-date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,MAAM,UAAU,sBAAsB,CACpC,KAAc,EACd,EAAE,gBAAgB,EAAE,IAAI,EAA2D;IAEnF,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,MAAM,EAAE,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IACnB,OAAO,UAAU,CAAC,EAAE,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|