@statezero/core 0.1.77 → 0.1.78
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.
|
@@ -72,10 +72,10 @@ function processFieldPath(fieldPath, value, ModelClass, options = {}) {
|
|
|
72
72
|
'exact', 'iexact', 'contains', 'icontains', 'startswith',
|
|
73
73
|
'istartswith', 'endswith', 'iendswith', 'in', 'gt', 'gte',
|
|
74
74
|
'lt', 'lte', 'isnull', 'regex', 'iregex', 'year', 'month',
|
|
75
|
-
'day', 'week_day', 'hour', 'minute', 'second'
|
|
75
|
+
'day', 'week_day', 'hour', 'minute', 'second', 'date', 'time'
|
|
76
76
|
];
|
|
77
77
|
// Date part lookups that can be followed by comparison lookups
|
|
78
|
-
const dateParts = ['year', 'month', 'day', 'week_day', 'hour', 'minute', 'second'];
|
|
78
|
+
const dateParts = ['year', 'month', 'day', 'week_day', 'hour', 'minute', 'second', 'date', 'time'];
|
|
79
79
|
// Comparison lookups that can follow date parts
|
|
80
80
|
const comparisonLookups = ['gt', 'gte', 'lt', 'lte', 'exact'];
|
|
81
81
|
let lookupChain = [];
|
|
@@ -380,6 +380,40 @@ function createDateOperations(timezone = 'UTC') {
|
|
|
380
380
|
const second = getDatePart(value, dt => dt.second);
|
|
381
381
|
return second !== null && second === params;
|
|
382
382
|
}, ownerQuery, options);
|
|
383
|
+
},
|
|
384
|
+
// Date - extract date portion (ignore time)
|
|
385
|
+
$date(params, ownerQuery, options) {
|
|
386
|
+
return createEqualsOperation((value) => {
|
|
387
|
+
if (!value)
|
|
388
|
+
return false;
|
|
389
|
+
const dateValue = value instanceof Date ? value : new Date(value);
|
|
390
|
+
if (isNaN(dateValue.getTime()))
|
|
391
|
+
return false;
|
|
392
|
+
// Convert both to timezone and get date portions
|
|
393
|
+
const luxonDate = DateTime.fromJSDate(dateValue).setZone(timezone);
|
|
394
|
+
const paramDate = DateTime.fromJSDate(new Date(params)).setZone(timezone);
|
|
395
|
+
// Compare year, month, and day
|
|
396
|
+
return luxonDate.year === paramDate.year &&
|
|
397
|
+
luxonDate.month === paramDate.month &&
|
|
398
|
+
luxonDate.day === paramDate.day;
|
|
399
|
+
}, ownerQuery, options);
|
|
400
|
+
},
|
|
401
|
+
// Time - extract time portion (ignore date)
|
|
402
|
+
$time(params, ownerQuery, options) {
|
|
403
|
+
return createEqualsOperation((value) => {
|
|
404
|
+
if (!value)
|
|
405
|
+
return false;
|
|
406
|
+
const dateValue = value instanceof Date ? value : new Date(value);
|
|
407
|
+
if (isNaN(dateValue.getTime()))
|
|
408
|
+
return false;
|
|
409
|
+
// Convert to timezone
|
|
410
|
+
const luxonDate = DateTime.fromJSDate(dateValue).setZone(timezone);
|
|
411
|
+
const paramDate = DateTime.fromJSDate(new Date(params)).setZone(timezone);
|
|
412
|
+
// Compare hour, minute, and second
|
|
413
|
+
return luxonDate.hour === paramDate.hour &&
|
|
414
|
+
luxonDate.minute === paramDate.minute &&
|
|
415
|
+
luxonDate.second === paramDate.second;
|
|
416
|
+
}, ownerQuery, options);
|
|
383
417
|
}
|
|
384
418
|
};
|
|
385
419
|
// Define part extractors for each date part with Django compatibility
|
package/package.json
CHANGED