2020-09-14 09:44:26 +00:00
|
|
|
import fromUnixTime from 'date-fns/fromUnixTime';
|
|
|
|
import format from 'date-fns/format';
|
2020-12-24 13:23:47 +00:00
|
|
|
import isToday from 'date-fns/isToday';
|
|
|
|
import isYesterday from 'date-fns/isYesterday';
|
2019-12-14 18:36:01 +00:00
|
|
|
|
2020-09-14 09:44:26 +00:00
|
|
|
export const formatUnixDate = (date, dateFormat = 'MMM dd, yyyy') => {
|
|
|
|
const unixDate = fromUnixTime(date);
|
|
|
|
return format(unixDate, dateFormat);
|
|
|
|
};
|
2020-12-24 13:23:47 +00:00
|
|
|
|
|
|
|
export const formatDate = ({ date, todayText, yesterdayText }) => {
|
|
|
|
const dateValue = new Date(date);
|
|
|
|
if (isToday(dateValue)) return todayText;
|
|
|
|
if (isYesterday(dateValue)) return yesterdayText;
|
|
|
|
return date;
|
|
|
|
};
|