drapcode-utility 2.4.6 → 2.4.7

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.
@@ -1,9 +1,10 @@
1
+ interface ExtraFieldSetting {
2
+ dateDisplayType?: string;
3
+ }
1
4
  interface DateField {
2
5
  fieldName: string;
3
6
  type: string;
4
- extraFieldSetting?: {
5
- dateDisplayType?: string;
6
- };
7
+ extraFieldSetting?: Map<string, ExtraFieldSetting>;
7
8
  }
8
9
  interface DateRangeValue {
9
10
  [key: string]: {
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.formatProjectDates = exports.timezoneDateParse = exports.nextDayDate = exports.getDateRangeValue = exports.getDateValue = exports.createLogsDateFormat = exports.createLoggerPreviousDateFormat = exports.createLoggerDateFormat = exports.DATE_REGEX = void 0;
7
7
  const drapcode_constant_1 = require("drapcode-constant");
8
+ const lodash_1 = __importDefault(require("lodash"));
8
9
  const moment_1 = __importDefault(require("moment"));
9
10
  const dateFormat = "YYYY-MM-DDTHH:mm:ss.SSS";
10
11
  exports.DATE_REGEX = /^[12]\d{3}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)(T| )?(([01][0-9]|2[0-3]):[0-5]\d(:[0-5]\d(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
@@ -192,7 +193,17 @@ const formatItemDates = (item, fields, dateFormat, reverse) => {
192
193
  Object.keys(item).forEach((fieldName) => {
193
194
  const field = fields.find((field) => field.fieldName === fieldName);
194
195
  if (field?.type === "date") {
195
- if (field?.extraFieldSetting?.dateDisplayType === "datetime-local") {
196
+ let dateDisplayType = "";
197
+ if (field?.extraFieldSetting) {
198
+ const extraFieldSetting = field?.extraFieldSetting;
199
+ if (lodash_1.default.isPlainObject(extraFieldSetting)) {
200
+ dateDisplayType = extraFieldSetting?.dateDisplayType;
201
+ }
202
+ else if (extraFieldSetting instanceof Map) {
203
+ dateDisplayType = extraFieldSetting?.get("dateDisplayType") || "";
204
+ }
205
+ }
206
+ if (dateDisplayType === "datetime-local") {
196
207
  item[fieldName] = (0, moment_1.default)(item[fieldName], dateTimeFormat).isValid()
197
208
  ? item[fieldName]
198
209
  : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
4
4
  "description": "DrapCode Utility",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",