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;
|
|
|
|
};
|
2021-03-13 06:14:28 +00:00
|
|
|
|
2021-03-13 08:36:25 +00:00
|
|
|
export const formatDigitToString = val => {
|
|
|
|
return val > 9 ? `${val}` : `0${val}`;
|
|
|
|
};
|
|
|
|
|
2022-04-18 12:45:20 +00:00
|
|
|
export const isTimeAfter = (h1, m1, h2, m2) => {
|
|
|
|
if (h1 < h2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h1 === h2) {
|
|
|
|
return m1 >= m2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2021-03-13 06:14:28 +00:00
|
|
|
};
|