2020-09-14 09:44:26 +00:00
|
|
|
import fromUnixTime from 'date-fns/fromUnixTime';
|
|
|
|
import format from 'date-fns/format';
|
2022-01-07 10:46:49 +00:00
|
|
|
import formatDistanceToNowStrict from 'date-fns/formatDistanceToNowStrict';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
methods: {
|
2021-02-11 06:40:08 +00:00
|
|
|
messageStamp(time, dateFormat = 'h:mm a') {
|
2020-09-14 09:44:26 +00:00
|
|
|
const unixTime = fromUnixTime(time);
|
2021-02-11 06:40:08 +00:00
|
|
|
return format(unixTime, dateFormat);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
dynamicTime(time) {
|
2020-09-14 09:44:26 +00:00
|
|
|
const unixTime = fromUnixTime(time);
|
2022-01-07 10:46:49 +00:00
|
|
|
return formatDistanceToNowStrict(unixTime, { addSuffix: true });
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|