fixed datetime filtering #912

This commit is contained in:
SPRINX0\prochazka
2024-10-08 14:38:46 +02:00
parent 4459347169
commit 6806620d90
6 changed files with 19 additions and 7 deletions

View File

@@ -24,6 +24,7 @@
"@types/parsimmon": "^1.10.1",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"date-fns": "^4.1.0",
"moment": "^2.24.0",
"parsimmon": "^1.13.0"
}

View File

@@ -1,11 +1,19 @@
import { arrayToHexString, isTypeDateTime } from 'dbgate-tools';
import moment from 'moment';
import { format, toDate } from 'date-fns';
import _isString from 'lodash/isString';
export type FilterMultipleValuesMode = 'is' | 'is_not' | 'contains' | 'begins' | 'ends';
function getDateStringWithoutTimeZone(dateString) {
if (_isString(dateString)) {
return dateString.replace(/Z|([+-]\d{2}:\d{2})$/, '');
}
return dateString;
}
export function getFilterValueExpression(value, dataType?) {
if (value == null) return 'NULL';
if (isTypeDateTime(dataType)) return moment(value).format('YYYY-MM-DD HH:mm:ss');
if (isTypeDateTime(dataType)) return format(toDate(getDateStringWithoutTimeZone(value)), 'yyyy-MM-dd HH:mm:ss');
if (value === true) return 'TRUE';
if (value === false) return 'FALSE';
if (value.$oid) return `ObjectId("${value.$oid}")`;

View File

@@ -58,7 +58,7 @@
},
"dependencies": {
"chartjs-plugin-zoom": "^1.2.0",
"date-fns": "^2.28.0",
"date-fns": "^4.1.0",
"debug": "^4.3.4",
"fuzzy": "^0.1.3",
"interval-operations": "^1.0.7",

View File

@@ -1,4 +1,3 @@
import { ca } from 'date-fns/locale';
import { apiCall, enableApi, getAuthCategory } from './utility/api';
import { getConfig } from './utility/metadataLoaders';
import { isAdminPage } from './utility/pageDefs';

View File

@@ -13,8 +13,7 @@
import { parseCellValue, safeJsonParse, stringifyCellValue } from 'dbgate-tools';
import { showSnackbarError } from '../utility/snackbar';
import ErrorMessageModal from './ErrorMessageModal.svelte';
import da from 'date-fns/locale/da';
export let onSave;
export let value;