Skip to content

Commit 2d2b4f2

Browse files
authored
fix: propertyType date edit should not convert to local timezone (#1694)(@AshotN)
1 parent d537b0d commit 2d2b4f2

File tree

1 file changed

+10
-2
lines changed
  • src/frontend/components/property-type/datetime

1 file changed

+10
-2
lines changed

src/frontend/components/property-type/datetime/edit.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ import { recordPropertyIsEqual } from '../record-property-is-equal.js'
66
import { PropertyLabel } from '../utils/property-label/index.js'
77
import allowOverride from '../../../hoc/allow-override.js'
88
import { useTranslation } from '../../../hooks/index.js'
9+
import { PropertyType } from '../../../../backend/index.js'
10+
11+
const formatDate = (val:string|null, propertyType: PropertyType) => {
12+
if (val) return (propertyType === 'date' ? `${val}T00:00:00` : val)
13+
return ''
14+
}
915

1016
const Edit: React.FC<EditPropertyProps> = (props) => {
1117
const { property, onChange, record } = props
12-
const value = (record.params && record.params[property.path]) || ''
18+
const value = record.params ? formatDate(record.params[property.path], property.type) : ''
1319
const error = record.errors && record.errors[property.path]
1420
const { tm } = useTranslation()
1521

@@ -19,7 +25,9 @@ const Edit: React.FC<EditPropertyProps> = (props) => {
1925
<DatePicker
2026
value={value}
2127
disabled={property.isDisabled}
22-
onChange={(date) => onChange(property.path, date)}
28+
onChange={(date) => {
29+
onChange(property.path, property.type === 'date' ? date?.substring(0, 10) ?? date : date)
30+
}}
2331
propertyType={property.type}
2432
{...property.props}
2533
/>

0 commit comments

Comments
 (0)