@litelens/design-system 1.0.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/LICENSE +201 -0
- package/README.md +129 -0
- package/dist/atoms/index.d.ts +215 -0
- package/dist/atoms/index.js +6 -0
- package/dist/chunk-3ZL7QROP.js +23 -0
- package/dist/chunk-7M2VOCYN.js +1 -0
- package/dist/chunk-7YPL4ZPM.js +41 -0
- package/dist/chunk-CPX26L4M.js +58 -0
- package/dist/chunk-FJE2X4E6.js +967 -0
- package/dist/chunk-GPI6G5NM.js +148 -0
- package/dist/chunk-NFJMUQY6.js +41 -0
- package/dist/chunk-NPDXDIXD.js +735 -0
- package/dist/chunk-OI5436K4.js +822 -0
- package/dist/chunk-QUNCRUSO.js +12 -0
- package/dist/chunk-TLJXC46A.js +1 -0
- package/dist/components/index.d.ts +254 -0
- package/dist/components/index.js +4 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +2 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +11 -0
- package/dist/libs/index.d.ts +48 -0
- package/dist/libs/index.js +4 -0
- package/dist/style.css +65 -0
- package/dist/styles.animation.css +18 -0
- package/dist/styles.js +1 -0
- package/dist/styles.palette.css +140 -0
- package/dist/styles.typography.css +57 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/index.js +2 -0
- package/package.json +88 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/utils/datetime.ts
|
|
2
|
+
function formatRelativeTime(isoString) {
|
|
3
|
+
if (!isoString || typeof isoString !== "string") {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
const date = new Date(isoString);
|
|
8
|
+
if (Number.isNaN(date.getTime())) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const now = /* @__PURE__ */ new Date();
|
|
12
|
+
const diffMs = now.getTime() - date.getTime();
|
|
13
|
+
if (diffMs < 0) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
const diffSeconds = Math.floor(diffMs / 1e3);
|
|
17
|
+
const diffMinutes = Math.floor(diffSeconds / 60);
|
|
18
|
+
const diffHours = Math.floor(diffMinutes / 60);
|
|
19
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
20
|
+
let relativeStr;
|
|
21
|
+
if (diffSeconds < 60) {
|
|
22
|
+
relativeStr = `${diffSeconds}s ago`;
|
|
23
|
+
} else if (diffMinutes < 60) {
|
|
24
|
+
const seconds = diffSeconds % 60;
|
|
25
|
+
if (seconds > 0) {
|
|
26
|
+
relativeStr = `${diffMinutes}m${seconds}s ago`;
|
|
27
|
+
} else {
|
|
28
|
+
relativeStr = `${diffMinutes}m ago`;
|
|
29
|
+
}
|
|
30
|
+
} else if (diffHours < 24) {
|
|
31
|
+
const minutes = diffMinutes % 60;
|
|
32
|
+
if (minutes > 0) {
|
|
33
|
+
relativeStr = `${diffHours}h${minutes}m ago`;
|
|
34
|
+
} else {
|
|
35
|
+
relativeStr = `${diffHours}h ago`;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
relativeStr = `${diffDays}d ago`;
|
|
39
|
+
}
|
|
40
|
+
return `${relativeStr} (${isoString})`;
|
|
41
|
+
} catch {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function formatTs(unix) {
|
|
46
|
+
if (!unix) return "";
|
|
47
|
+
return new Date(unix * 1e3).toLocaleString(void 0, {
|
|
48
|
+
year: "numeric",
|
|
49
|
+
month: "2-digit",
|
|
50
|
+
day: "2-digit",
|
|
51
|
+
hour: "2-digit",
|
|
52
|
+
minute: "2-digit",
|
|
53
|
+
second: "2-digit",
|
|
54
|
+
hour12: false
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { formatRelativeTime, formatTs };
|