diff --git a/src/controller.ts b/src/controller.ts index 4bcf6b32..e87de0c2 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -84,18 +84,24 @@ export class TextDecorator { const momentThen = moment(dateThen); const months = momentNow.diff(momentThen, 'months'); + if(months > 0) + { + return months + ' months ago'; + } + const days = momentNow.diff(momentThen, 'days'); + if(days >= 1) + { + return days == 1 ? 'yesterday' : (days + ' days ago'); + } - if (months <= 1) { - if (days == 0) { - return 'today'; - } else if (days == 1) { - return 'yesterday'; - } else { - return days + ' days ago'; - } - } else { - return months + ' months ago'; + const hours = momentNow.diff(momentThen, 'hours'); + if(hours > 0) + { + return hours + ' hours ago'; } + + const minutes = momentNow.diff(momentThen, 'minutes') + return minutes + ' minutes ago'; } } \ No newline at end of file