Skip to content

Commit 577410f

Browse files
authored
Merge pull request #2571 from appwrite/fix-SER-529-datetime-local-to-utc-filters
2 parents 4f19450 + cdff501 commit 577410f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/lib/components/filters/content.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import type { Column } from '$lib/helpers/types';
1515
import type { Writable } from 'svelte/store';
1616
import { TagList } from '.';
17+
import { toLocalDateTimeISO } from '$lib/helpers/date';
1718
import { Icon, Layout } from '@appwrite.io/pink-svelte';
1819
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
1920
@@ -79,7 +80,7 @@
7980
value = column?.array ? [] : null;
8081
if (column?.type === 'datetime') {
8182
const now = new Date();
82-
value = now.toISOString().slice(0, 16);
83+
value = toLocalDateTimeISO(now.toISOString()).slice(0, 16);
8384
}
8485
// Initialize spatial data with default values
8586
if (column?.type === 'point') {
@@ -108,7 +109,11 @@
108109
if (isDistanceOperator && distanceValue !== null && value !== null) {
109110
addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
110111
} else {
111-
addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
112+
const preparedValue =
113+
column?.type === 'datetime' && typeof value === 'string' && value
114+
? new Date(value).toISOString()
115+
: value;
116+
addFilter(columnsArray, columnId, operatorKey, preparedValue, arrayValues);
112117
}
113118
114119
columnId = null;

src/lib/components/filters/filtersModal.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@
5757
}
5858
5959
function addCondition() {
60-
const newTag = generateTag(selectedColumn, operatorKey, value || arrayValues);
60+
const preparedValue =
61+
column?.type === 'datetime' && typeof value === 'string' && value
62+
? new Date(value).toISOString()
63+
: value;
64+
const newTag = generateTag(selectedColumn, operatorKey, preparedValue || arrayValues);
6165
if (localTags.some((t) => t.tag === newTag.tag && t.value === newTag.value)) {
6266
return;
6367
} else {
@@ -66,7 +70,7 @@
6670
{
6771
id: selectedColumn,
6872
operator: operatorKey,
69-
value: value,
73+
value: preparedValue,
7074
arrayValues: arrayValues
7175
}
7276
];

0 commit comments

Comments
 (0)