import DatePickerGroup from './DatePickerGroup';
import { DatePickerHelper } from './DatePickerHelper';

export interface StringDatePickerGroupProps
  extends DatePickerHelper<string | undefined | null> {}

/**
 * Date picker input that consumes and outputs as a date only string in ISO format `YYYY-MM-DDTHH:mm:ss.sssZ` or `±YYYYYY-MM-DDTHH:mm:ss.sssZ`
 *
 * If you need `YYYY-MM-DD` format use `<StringDateOnlyPickerGroup/>`.
 */
export default function StringDatePickerGroup(
  props: StringDatePickerGroupProps
) {
  return <DatePickerGroup {...props} convert={convertToDateOnly} />;
}

function convertToDateOnly(arg: Date) {
  return arg.toISOString();
}
