Skip to content

Commit

Permalink
fix: propertyType date edit should not convert to local timezone (#1694
Browse files Browse the repository at this point in the history
…)(@AshotN)
  • Loading branch information
AshotN authored Aug 8, 2024
1 parent d537b0d commit 2d2b4f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/frontend/components/property-type/datetime/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import { recordPropertyIsEqual } from '../record-property-is-equal.js'
import { PropertyLabel } from '../utils/property-label/index.js'
import allowOverride from '../../../hoc/allow-override.js'
import { useTranslation } from '../../../hooks/index.js'
import { PropertyType } from '../../../../backend/index.js'

const formatDate = (val:string|null, propertyType: PropertyType) => {
if (val) return (propertyType === 'date' ? `${val}T00:00:00` : val)
return ''
}

const Edit: React.FC<EditPropertyProps> = (props) => {
const { property, onChange, record } = props
const value = (record.params && record.params[property.path]) || ''
const value = record.params ? formatDate(record.params[property.path], property.type) : ''
const error = record.errors && record.errors[property.path]
const { tm } = useTranslation()

Expand All @@ -19,7 +25,9 @@ const Edit: React.FC<EditPropertyProps> = (props) => {
<DatePicker
value={value}
disabled={property.isDisabled}
onChange={(date) => onChange(property.path, date)}
onChange={(date) => {
onChange(property.path, property.type === 'date' ? date?.substring(0, 10) ?? date : date)
}}
propertyType={property.type}
{...property.props}
/>
Expand Down

0 comments on commit 2d2b4f2

Please sign in to comment.