import { useMemo } from 'react' ; import format from 'date-fns/format' ; import localeIS from 'date-fns/locale/is' ; import localeEN from 'date-fns/locale/en-GB' ; import { useI18n } from './useI18n' ; const localeMap = { is : localeIS , en : localeEN , } ; export const useDateUtils = ( ) => { const { activeLocale } = useI18n ( ) ; return useMemo ( ( ) => { const locale = localeMap [ activeLocale ] ; return { format : ( date , dateFormat , options = { } ) => format ( date , dateFormat , { locale , ... options } ) , /**
             * returns the name of the (0-indexed) month according to the current locale for this month
             */ getMonthByIndex : ( idx ) => { const d = new Date ( 0 , idx , 2 ) ; return format ( d , 'MMMM' , { locale } ) ; } , locale , } ; } , [ activeLocale ] ) ; } ;