adminforth 2.22.0-next.18 → 2.22.0-next.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -598,4 +598,22 @@ export function generateMessageHtmlForRecordChange(changedFields: Record<string,
598
598
  const listHtml = items ? `<ul class="mt-2 list-disc list-inside">${items}</ul>` : '';
599
599
  const messageHtml = `<div>${escapeHtml(t('There are unsaved changes. Are you sure you want to leave this page?'))}${listHtml}</div>`;
600
600
  return messageHtml;
601
+ }
602
+
603
+ export function getTimeAgoString(date: Date): string {
604
+ const now = new Date();
605
+ const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
606
+
607
+ if (diffInSeconds < 60) {
608
+ return `${diffInSeconds} ${diffInSeconds === 1 ? 'second' : 'seconds'} ago`;
609
+ } else if (diffInSeconds < 3600) {
610
+ const minutes = Math.floor(diffInSeconds / 60);
611
+ return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'} ago`;
612
+ } else if (diffInSeconds < 86400) {
613
+ const hours = Math.floor(diffInSeconds / 3600);
614
+ return `${hours} ${hours === 1 ? 'hour' : 'hours'} ago`;
615
+ } else {
616
+ const days = Math.floor(diffInSeconds / 86400);
617
+ return `${days} ${days === 1 ? 'day' : 'days'} ago`;
618
+ }
601
619
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.22.0-next.18",
3
+ "version": "2.22.0-next.19",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",