getFullDateOffset.ts 505 B

12345678910111213141516171819
  1. import { isFunction } from 'lodash';
  2. import { strings } from '../constants';
  3. import { format } from 'date-fns';
  4. /**
  5. * Calculate the date string offset from the date
  6. * @param {*} fn
  7. * @param {*} date
  8. */
  9. const getFullDateOffset = (fn: any, date: any) => {
  10. if (!date) {
  11. return '';
  12. }
  13. const getDate = new Date(date);
  14. const offsetDate = isFunction(fn) ? fn(getDate) : getDate;
  15. return format(new Date(offsetDate), strings.FORMAT_FULL_DATE);
  16. };
  17. export default getFullDateOffset;