@molopos/shared 2.0.88 → 2.0.89

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/date/index.d.ts CHANGED
@@ -7,13 +7,8 @@ interface PropsRecurrence {
7
7
  recurrence: RecurrenceEnum;
8
8
  }
9
9
  /**
10
- * Format a date to a string
11
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
12
- * @param locale - The locale to use (e.g. "en-US", "it-IT", "fr-FR", etc.)
13
- * @returns The formatted date (e.g. "1 Jan 2026", "1 Jan 2026 00:00", etc.)
14
- *
15
10
  * @example
16
- * formateDate("2026-01-01", "en-US"); // "1 Jan 2026"
11
+ * formateDate("2026-01-01", "en-US"); // "1 Jan 2026 00:00"
17
12
  */
18
13
  export declare const formateDate: (date: Date, locale: string) => string;
19
14
  /**
@@ -27,26 +22,26 @@ export declare const formateDate: (date: Date, locale: string) => string;
27
22
  */
28
23
  export declare const formateddLLLyyyy: (date: DateLike, locale: string) => string;
29
24
  export declare const formateYYDDMM: (date: Date, locale: string) => string;
25
+ /**
26
+ * @example
27
+ * formateHHmm("2026-01-01", "en-US"); // "00:00"
28
+ */
30
29
  export declare const formateHHmm: (date: Date, locale: string) => string;
31
30
  /**
32
- * Format a date to a string
33
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
34
- * @returns The formatted date (e.g. "01-01-2026", "01-01-2026 00:00:00", etc.)
35
- *
31
+ * @example
32
+ * formatDateDDMMYYToUtc("2026-01-01", "en"); // "01/01/2026"
33
+ */
34
+ export declare const formatDateDDMMYYToUtc: (date: Date, locale: string) => string;
35
+ /**
36
36
  * @example
37
37
  * formatDateFnsToDdMMYYYY("2026-01-01"); // "01-01-2026"
38
38
  */
39
39
  export declare const formatDateFnsToDdMMYYYY: (date: Date) => string;
40
40
  /**
41
- * Format a date to a string
42
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
43
- * @returns The formatted date (e.g. "01-01-2026 00:00:00", "01-01-2026 00:00:00", etc.)
44
- *
45
41
  * @example
46
42
  * formatDateFnsToDdMMYYYYHHmmss("2026-01-01"); // "01-01-2026 00:00:00"
47
43
  */
48
44
  export declare const formatDateFnsToDdMMYYYYHHmm: (date: Date) => string;
49
- export declare const formatDateDDMMYYToUtc: (date: Date, locale: string) => string;
50
45
  export declare const formateToT: (date: Date) => string;
51
46
  export declare const dateTimeNowUtc: () => Date;
52
47
  export declare const formateToCccc: (date: Date, locale: string) => string;
@@ -111,5 +106,5 @@ export declare const subtractDaysToDateTime: (date: Date, value: number) => Date
111
106
  * @example
112
107
  * recurrenceDate({ date: new Date(), recurrence: RecurrenceEnum.Monthly }) // 23/06/2026
113
108
  */
114
- export declare const recurrenceDate: ({ date, recurrence, duration, isRecurrence, }: PropsRecurrence) => Date;
109
+ export declare const recurrenceDate: ({ date, recurrence, duration, isRecurrence, }: PropsRecurrence) => Date | null;
115
110
  export {};
package/date/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recurrenceDate = exports.subtractDaysToDateTime = exports.subtractDaysToDateTimeNowUtc = exports.formateDateUnixInteger = exports.dateTimeNowUtcUnixInteger = exports.formateTDate = exports.formateToUnixIntegerddLLLyyyy = exports.formateDDDateISO = exports.formateddLLDate = exports.formateDDDate = exports.formateMMLongDate = exports.addDaysToTimeNowUtcDate = exports.viewYyformateToYyyy = exports.formateToyyyy = exports.formateToRFC2822 = exports.formateToLLLL = exports.formateTodd = exports.formateToCccc = exports.dateTimeNowUtc = exports.formateToT = exports.formatDateDDMMYYToUtc = exports.formatDateFnsToDdMMYYYYHHmm = exports.formatDateFnsToDdMMYYYY = exports.formateHHmm = exports.formateYYDDMM = exports.formateddLLLyyyy = exports.formateDate = void 0;
3
+ exports.recurrenceDate = exports.subtractDaysToDateTime = exports.subtractDaysToDateTimeNowUtc = exports.formateDateUnixInteger = exports.dateTimeNowUtcUnixInteger = exports.formateTDate = exports.formateToUnixIntegerddLLLyyyy = exports.formateDDDateISO = exports.formateddLLDate = exports.formateDDDate = exports.formateMMLongDate = exports.addDaysToTimeNowUtcDate = exports.viewYyformateToYyyy = exports.formateToyyyy = exports.formateToRFC2822 = exports.formateToLLLL = exports.formateTodd = exports.formateToCccc = exports.dateTimeNowUtc = exports.formateToT = exports.formatDateFnsToDdMMYYYYHHmm = exports.formatDateFnsToDdMMYYYY = exports.formatDateDDMMYYToUtc = exports.formateHHmm = exports.formateYYDDMM = exports.formateddLLLyyyy = exports.formateDate = void 0;
4
4
  const date_fns_1 = require("date-fns");
5
5
  const locale_1 = require("date-fns/locale");
6
6
  const luxon_1 = require("luxon");
@@ -14,22 +14,18 @@ const dataFnsLocale = {
14
14
  de: locale_1.de,
15
15
  };
16
16
  /**
17
- * Format a date to a string
18
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
19
- * @param locale - The locale to use (e.g. "en-US", "it-IT", "fr-FR", etc.)
20
- * @returns The formatted date (e.g. "1 Jan 2026", "1 Jan 2026 00:00", etc.)
21
- *
22
17
  * @example
23
- * formateDate("2026-01-01", "en-US"); // "1 Jan 2026"
18
+ * formateDate("2026-01-01", "en-US"); // "1 Jan 2026 00:00"
24
19
  */
25
20
  const formateDate = (date, locale) => {
26
21
  let dateReturn = null;
27
22
  const todaysDate = (0, exports.dateTimeNowUtc)();
28
23
  const currentYear = todaysDate.getFullYear();
29
- const dateInit = luxon_1.DateTime.fromISO(String(date));
30
- const dateYear = Number(dateInit.toFormat("yyyy"));
24
+ const dateYear = (0, date_fns_1.getYear)(date);
31
25
  if (currentYear === dateYear) {
32
- dateReturn = dateInit.setLocale(locale).toFormat("dd MMM HH:mm");
26
+ dateReturn = (0, date_fns_1.format)(date, "PPp", {
27
+ locale: dataFnsLocale[locale],
28
+ });
33
29
  }
34
30
  else {
35
31
  dateReturn = (0, exports.formatDateDDMMYYToUtc)(date, locale);
@@ -56,36 +52,30 @@ const formateYYDDMM = (date, locale) => {
56
52
  return dateInit.setLocale(locale).toFormat("ff");
57
53
  };
58
54
  exports.formateYYDDMM = formateYYDDMM;
59
- const formateHHmm = (date, locale) => {
60
- const dateInit = luxon_1.DateTime.fromISO(String(date));
61
- return dateInit.setLocale(locale).toFormat("t");
62
- };
55
+ /**
56
+ * @example
57
+ * formateHHmm("2026-01-01", "en-US"); // "00:00"
58
+ */
59
+ const formateHHmm = (date, locale) => (0, date_fns_1.format)(date, "p", { locale: dataFnsLocale[locale] });
63
60
  exports.formateHHmm = formateHHmm;
64
61
  /**
65
- * Format a date to a string
66
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
67
- * @returns The formatted date (e.g. "01-01-2026", "01-01-2026 00:00:00", etc.)
68
- *
62
+ * @example
63
+ * formatDateDDMMYYToUtc("2026-01-01", "en"); // "01/01/2026"
64
+ */
65
+ const formatDateDDMMYYToUtc = (date, locale) => (0, date_fns_1.format)(date, "P", { locale: dataFnsLocale[locale] });
66
+ exports.formatDateDDMMYYToUtc = formatDateDDMMYYToUtc;
67
+ /**
69
68
  * @example
70
69
  * formatDateFnsToDdMMYYYY("2026-01-01"); // "01-01-2026"
71
70
  */
72
71
  const formatDateFnsToDdMMYYYY = (date) => (0, date_fns_1.format)(date, "dd-MM-yyyy");
73
72
  exports.formatDateFnsToDdMMYYYY = formatDateFnsToDdMMYYYY;
74
73
  /**
75
- * Format a date to a string
76
- * @param date - The date to format (e.g. "2026-01-01", "2026-01-01T00:00:00.000Z", etc.)
77
- * @returns The formatted date (e.g. "01-01-2026 00:00:00", "01-01-2026 00:00:00", etc.)
78
- *
79
74
  * @example
80
75
  * formatDateFnsToDdMMYYYYHHmmss("2026-01-01"); // "01-01-2026 00:00:00"
81
76
  */
82
77
  const formatDateFnsToDdMMYYYYHHmm = (date) => (0, date_fns_1.format)(date, "dd-MM-yyyy HH:mm");
83
78
  exports.formatDateFnsToDdMMYYYYHHmm = formatDateFnsToDdMMYYYYHHmm;
84
- const formatDateDDMMYYToUtc = (date, locale) => {
85
- const dateInit = luxon_1.DateTime.fromISO(String(date));
86
- return dateInit.setLocale(locale).toFormat("D");
87
- };
88
- exports.formatDateDDMMYYToUtc = formatDateDDMMYYToUtc;
89
79
  const formateToT = (date) => luxon_1.DateTime.fromJSDate(date).toFormat("T");
90
80
  exports.formateToT = formateToT;
91
81
  const dateTimeNowUtc = () => luxon_1.DateTime.utc().toJSDate();
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.88","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"class-transformer":"^0.5.1","date-fns":"^4.4.0","luxon":"^3.7.2"}}
1
+ {"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.89","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"class-transformer":"^0.5.1","date-fns":"^4.4.0","luxon":"^3.7.2"}}