plac-micro-common 1.2.71 → 1.2.73

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.
@@ -2,3 +2,4 @@ export * from "../http";
2
2
  export * from "../libs";
3
3
  export * from "../models";
4
4
  export * from "../utils";
5
+ export * from "../constants";
@@ -18,3 +18,4 @@ __exportStar(require("../http"), exports);
18
18
  __exportStar(require("../libs"), exports);
19
19
  __exportStar(require("../models"), exports);
20
20
  __exportStar(require("../utils"), exports);
21
+ __exportStar(require("../constants"), exports);
@@ -1,3 +1,4 @@
1
1
  export * from "../components";
2
2
  export * from "../types";
3
- export * from '../utils/frontend';
3
+ export * from "../utils/frontend";
4
+ export * from "../constants";
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("../components"), exports);
18
18
  __exportStar(require("../types"), exports);
19
19
  __exportStar(require("../utils/frontend"), exports);
20
+ __exportStar(require("../constants"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const DISPLAY_DATE_FORMAT = "DD MMM YYYY";
2
+ export declare const DISPLAY_DATE_TIME_FORMAT = "DD MMM YYYY HH:mm";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DISPLAY_DATE_TIME_FORMAT = exports.DISPLAY_DATE_FORMAT = void 0;
4
+ exports.DISPLAY_DATE_FORMAT = "DD MMM YYYY";
5
+ exports.DISPLAY_DATE_TIME_FORMAT = "DD MMM YYYY HH:mm";
@@ -1,2 +1,4 @@
1
1
  export declare function buildFullName(first?: string | null, last?: string | null): string | null;
2
2
  export declare function buildFullNameKh(firstKh?: string | null, lastKh?: string | null): string | null;
3
+ export declare function displayDate(value?: Date | string | number | null, format?: string): string;
4
+ export declare function displayDateTime(value?: Date | string | number | null, format?: string): string;
@@ -1,12 +1,35 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.buildFullName = buildFullName;
4
7
  exports.buildFullNameKh = buildFullNameKh;
8
+ exports.displayDate = displayDate;
9
+ exports.displayDateTime = displayDateTime;
10
+ const dayjs_1 = __importDefault(require("dayjs"));
11
+ const constants_1 = require("../../constants");
5
12
  function buildFullName(first, last) {
6
- const v = `${first ?? ''} ${last ?? ''}`.trim();
13
+ const v = `${first ?? ""} ${last ?? ""}`.trim();
7
14
  return v.length ? v : null;
8
15
  }
9
16
  function buildFullNameKh(firstKh, lastKh) {
10
- const v = `${lastKh ?? ''} ${firstKh ?? ''}`.trim();
17
+ const v = `${lastKh ?? ""} ${firstKh ?? ""}`.trim();
11
18
  return v.length ? v : null;
12
19
  }
20
+ function displayDate(value, format = constants_1.DISPLAY_DATE_FORMAT) {
21
+ if (!value)
22
+ return "-";
23
+ const date = (0, dayjs_1.default)(value);
24
+ if (!date.isValid())
25
+ return "-";
26
+ return date.format(format);
27
+ }
28
+ function displayDateTime(value, format = constants_1.DISPLAY_DATE_TIME_FORMAT) {
29
+ if (!value)
30
+ return "-";
31
+ const date = (0, dayjs_1.default)(value);
32
+ if (!date.isValid())
33
+ return "-";
34
+ return date.format(format);
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plac-micro-common",
3
- "version": "1.2.71",
3
+ "version": "1.2.73",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -33,6 +33,7 @@
33
33
  "@types/jsonwebtoken": "^9.0.10",
34
34
  "@types/react": "^19.2.10",
35
35
  "axios": "^1.13.2",
36
+ "dayjs": "^1.11.19",
36
37
  "express": "^5.2.1",
37
38
  "ioredis": "^5.9.1",
38
39
  "jsonwebtoken": "^9.0.3",