@tap-payments/os-micro-frontend-shared 0.1.224-test.1 → 0.1.224-test.3
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.
- package/build/utils/date.d.ts +3 -0
- package/build/utils/date.js +11 -0
- package/package.json +2 -2
package/build/utils/date.d.ts
CHANGED
|
@@ -38,3 +38,6 @@ export declare const generatePastYearList: (length?: number) => {
|
|
|
38
38
|
label: number;
|
|
39
39
|
}[];
|
|
40
40
|
export declare function secondsToTimeString(seconds: number): string;
|
|
41
|
+
type TimeUnit = 'seconds' | 'minutes' | 'hours' | 'days';
|
|
42
|
+
export declare function isWithinTimeAgo(timestampMs: number, amount: number, unit?: TimeUnit): boolean;
|
|
43
|
+
export {};
|
package/build/utils/date.js
CHANGED
|
@@ -216,3 +216,14 @@ export function secondsToTimeString(seconds) {
|
|
|
216
216
|
}
|
|
217
217
|
return `${pad(minutes)}:${pad(secondsValue)}`;
|
|
218
218
|
}
|
|
219
|
+
export function isWithinTimeAgo(timestampMs, amount, unit = 'seconds') {
|
|
220
|
+
const unitSeconds = {
|
|
221
|
+
seconds: 1,
|
|
222
|
+
minutes: 60,
|
|
223
|
+
hours: 3600,
|
|
224
|
+
days: 86400,
|
|
225
|
+
};
|
|
226
|
+
const now = Date.now();
|
|
227
|
+
const diffSeconds = (now - timestampMs) / 1000;
|
|
228
|
+
return diffSeconds < amount * unitSeconds[unit];
|
|
229
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.224-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.224-test.3",
|
|
5
|
+
"testVersion": 3,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|