import { useCallback } from "react" ; import useDateTimeFormat from "./useDateTimeFormat" ; export default function useDateTimeFormatter ( options ) { const formatter = useDateTimeFormat ( options ) ; const format = useCallback ( ( date ) => { if ( typeof date === "string" || typeof date === "number" ) { return formatter . format ( new Date ( date ) ) ; } return formatter . format ( date ) ; } , [ formatter ] ) ; return format ; }