treat filter datetime inputs as local; convert to UTC on apply

This commit is contained in:
Harsh Mahajan
2025-11-06 15:39:40 +05:30
parent 49bdca652c
commit cdff501429
2 changed files with 13 additions and 4 deletions
+7 -2
View File
@@ -14,6 +14,7 @@
import type { Column } from '$lib/helpers/types';
import type { Writable } from 'svelte/store';
import { TagList } from '.';
import { toLocalDateTimeISO } from '$lib/helpers/date';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
@@ -79,7 +80,7 @@
value = column?.array ? [] : null;
if (column?.type === 'datetime') {
const now = new Date();
value = now.toISOString().slice(0, 16);
value = toLocalDateTimeISO(now.toISOString()).slice(0, 16);
}
// Initialize spatial data with default values
if (column?.type === 'point') {
@@ -108,7 +109,11 @@
if (isDistanceOperator && distanceValue !== null && value !== null) {
addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
} else {
addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
const preparedValue =
column?.type === 'datetime' && typeof value === 'string' && value
? new Date(value).toISOString()
: value;
addFilter(columnsArray, columnId, operatorKey, preparedValue, arrayValues);
}
columnId = null;
@@ -57,7 +57,11 @@
}
function addCondition() {
const newTag = generateTag(selectedColumn, operatorKey, value || arrayValues);
const preparedValue =
column?.type === 'datetime' && typeof value === 'string' && value
? new Date(value).toISOString()
: value;
const newTag = generateTag(selectedColumn, operatorKey, preparedValue || arrayValues);
if (localTags.some((t) => t.tag === newTag.tag && t.value === newTag.value)) {
return;
} else {
@@ -66,7 +70,7 @@
{
id: selectedColumn,
operator: operatorKey,
value: value,
value: preparedValue,
arrayValues: arrayValues
}
];