mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Different logic for relative time
This commit is contained in:
parent
de45a0f9d5
commit
abe5d02d93
1 changed files with 4 additions and 3 deletions
|
@ -27,11 +27,12 @@ export default function RelativeTime({ datetime, format }) {
|
|||
raf = requestAnimationFrame(() => {
|
||||
let str;
|
||||
if (format === 'micro') {
|
||||
// If date <= 7 days
|
||||
if (date.diff(dayjs(), 'day') >= -7) {
|
||||
// If date <= 1 day ago or day is within this year
|
||||
const now = dayjs();
|
||||
const dayDiff = now.diff(date, 'day');
|
||||
if (dayDiff <= 1 || now.year() === date.year()) {
|
||||
str = date.twitter();
|
||||
} else {
|
||||
// If date > 7 days
|
||||
str = dtf.format(date.toDate());
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue