mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed getPrettyDate for closest dates
This commit is contained in:
parent
ad72e5f867
commit
b1279e8d4d
1 changed files with 3 additions and 1 deletions
|
@ -2,6 +2,7 @@ import { IFile, ValueOf } from '~/redux/types';
|
||||||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||||
import isAfter from 'date-fns/isAfter';
|
import isAfter from 'date-fns/isAfter';
|
||||||
import differenceInMonths from 'date-fns/differenceInMonths';
|
import differenceInMonths from 'date-fns/differenceInMonths';
|
||||||
|
import differenceInMinutes from 'date-fns/differenceInMinutes';
|
||||||
import ru from 'date-fns/locale/ru';
|
import ru from 'date-fns/locale/ru';
|
||||||
import Axios from 'axios';
|
import Axios from 'axios';
|
||||||
import { PRESETS } from '~/constants/urls';
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
@ -128,7 +129,8 @@ export const getPrettyDate = (date: string): string => {
|
||||||
return format(new Date(date), 'd MMMM yyyy', { locale: ru });
|
return format(new Date(date), 'd MMMM yyyy', { locale: ru });
|
||||||
}
|
}
|
||||||
|
|
||||||
return isAfter(new Date(date), new Date())
|
return isAfter(new Date(date), new Date()) ||
|
||||||
|
differenceInMinutes(new Date(), new Date(date)) <= 30
|
||||||
? 'Только что'
|
? 'Только что'
|
||||||
: formatDistanceToNow(new Date(date), {
|
: formatDistanceToNow(new Date(date), {
|
||||||
locale: ru,
|
locale: ru,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue