# Dates

`DDatePicker` wraps react-datepicker. Exact props: `widgets-get-component-props`; the react-datepicker props it forwards are listed under `forwardedProps`.

---

## DDatePicker

The selected date is react-datepicker's `selected` (a `Date` or `null`), and `onChange` receives a `Date` or `null`:

```tsx
const [date, setDate] = useState<Date | null>(null);

<DDatePicker
  inputLabel={t('transfer.date')}
  selected={date}
  onChange={(next) => setDate(next)}
/>
```

| Prop | Use |
|------|-----|
| `inputLabel`, `inputHint`, `inputAriaLabel` | Label, help text and accessible name of the field |
| `invalid`, `valid` | Validation state |
| `dateFormat`, `locale` | Display format and locale |
| `selectsRange` | Select a range; `onChange` then receives `[start, end]` |
| `showTimeSelect`, `showTimeInput`, `timeFormat` | Time selection |
| `isClearable`, `disabled`, `readOnly`, `placeholder` | State |

- The field's label props are `inputLabel` and `inputHint`, not `label` and `hint`.
- `value` is the raw text of the input, not the selected date.
- Keep dates in state as `Date`. When a date goes to an API, convert it in the feature's `api/` layer (see `modyo://docs/widgets/patterns-api-clients`).

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `label={…}` | `inputLabel={…}` |
| `value={date}` to set the selected date | `selected={date}` |
| `onChange={(e) => …e.target.value}` | `onChange={(next) => setDate(next)}` (a `Date` or `null`) |
