drapcode-utility 2.6.5 → 2.6.6
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.
|
@@ -26,6 +26,6 @@ export declare const createLogsDateFormat: (timezone?: string) => string;
|
|
|
26
26
|
export declare const getDateValue: (value: string, timezone?: string, fieldType?: string) => string;
|
|
27
27
|
export declare const getDateRangeValue: (key: string, field: string, value: string) => DateRangeValue;
|
|
28
28
|
export declare const nextDayDate: (date: string | Date) => string;
|
|
29
|
-
export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean) =>
|
|
29
|
+
export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean, isDateTime?: any) => any;
|
|
30
30
|
export declare const formatProjectDates: (item: Record<string, any> | Record<string, any>[], dateFormat: string, fields: DateField[], reverse: boolean) => Record<string, any> | Record<string, any>[];
|
|
31
31
|
export {};
|
package/build/utils/date-util.js
CHANGED
|
@@ -161,8 +161,10 @@ const nextDayDate = (date) => {
|
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
exports.nextDayDate = nextDayDate;
|
|
164
|
-
const timezoneDateParse = (value, nextDay = false, prevDay = false) => {
|
|
164
|
+
const timezoneDateParse = (value, nextDay = false, prevDay = false, isDateTime = null) => {
|
|
165
165
|
try {
|
|
166
|
+
// Checking False because in case of null and true we need date with time
|
|
167
|
+
const format = isDateTime === false ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm:ss";
|
|
166
168
|
let timeZoneDate = (0, moment_1.default)(value);
|
|
167
169
|
if (!timeZoneDate.isValid()) {
|
|
168
170
|
throw new Error("Invalid date input");
|
|
@@ -173,9 +175,9 @@ const timezoneDateParse = (value, nextDay = false, prevDay = false) => {
|
|
|
173
175
|
if (prevDay && value.length <= 10) {
|
|
174
176
|
timeZoneDate = timeZoneDate.subtract(1, "days");
|
|
175
177
|
}
|
|
176
|
-
const formatted = timeZoneDate.format(
|
|
177
|
-
return new Date(formatted);
|
|
178
|
-
// return
|
|
178
|
+
const formatted = timeZoneDate.format(format);
|
|
179
|
+
return typeof isDateTime === "boolean" ? formatted : new Date(formatted);
|
|
180
|
+
// return new Date(formatted);
|
|
179
181
|
}
|
|
180
182
|
catch (error) {
|
|
181
183
|
console.error("Error in timezoneDateParse:", error);
|
|
@@ -83,8 +83,7 @@ const getSearchObjQuery = (searchObj, searchQueryTypeObj) => {
|
|
|
83
83
|
].includes(searchQueryTypeKey)) {
|
|
84
84
|
const isDateTime = ["datetime", ...drapcode_constant_1.systemDateField].includes(searchQueryTypeKey);
|
|
85
85
|
if (key.startsWith("start_") || key.startsWith("end_")) {
|
|
86
|
-
let fieldKey = key.replace(
|
|
87
|
-
fieldKey = fieldKey.replace("end_", "");
|
|
86
|
+
let fieldKey = key.replace(/^start_/, "").replace(/^end_/, "");
|
|
88
87
|
searchAggregateQuery.push({
|
|
89
88
|
$addFields: {
|
|
90
89
|
[`_${key}`]: { $toString: `$${fieldKey}` },
|
|
@@ -93,14 +92,14 @@ const getSearchObjQuery = (searchObj, searchQueryTypeObj) => {
|
|
|
93
92
|
if (key.startsWith("start_")) {
|
|
94
93
|
likeQuery.push({
|
|
95
94
|
[`_${key}`]: {
|
|
96
|
-
$gte: (0, date_util_1.timezoneDateParse)(value,
|
|
95
|
+
$gte: (0, date_util_1.timezoneDateParse)(value, false, false, isDateTime),
|
|
97
96
|
},
|
|
98
97
|
});
|
|
99
98
|
}
|
|
100
99
|
else if (key.startsWith("end_")) {
|
|
101
100
|
likeQuery.push({
|
|
102
101
|
[`_${key}`]: {
|
|
103
|
-
$lt: (0, date_util_1.timezoneDateParse)(value, isDateTime),
|
|
102
|
+
$lt: (0, date_util_1.timezoneDateParse)(value, true, false, isDateTime),
|
|
104
103
|
},
|
|
105
104
|
});
|
|
106
105
|
}
|