Download dashboard/src/lib/formatters.js from RavindranadhM/Manufacturing-Monitoring-System: direct link, hf CLI and curl.
- Browser
- Download file 992 Bytes
-
https://huggingface.co/spaces/RavindranadhM/Manufacturing-Monitoring-System/resolve/main/dashboard/src/lib/formatters.js
- Command line
-
hf download hf://spaces/RavindranadhM/Manufacturing-Monitoring-System/dashboard/src/lib/formatters.js
-
curl -L -o formatters.js https://huggingface.co/spaces/RavindranadhM/Manufacturing-Monitoring-System/resolve/main/dashboard/src/lib/formatters.js
992 Bytes
| export function formatDateTime(value) { | |
| if (!value) return "Waiting for signal" | |
| const parsed = new Date(value) | |
| if (Number.isNaN(parsed.getTime())) return value | |
| return new Intl.DateTimeFormat("en-IN", { | |
| year: "numeric", | |
| month: "short", | |
| day: "numeric", | |
| hour: "numeric", | |
| minute: "2-digit", | |
| second: "2-digit", | |
| }).format(parsed) | |
| } | |
| export function formatShortTime(value) { | |
| if (!value) return "--" | |
| const parsed = new Date(value) | |
| if (Number.isNaN(parsed.getTime())) return value | |
| return new Intl.DateTimeFormat("en-IN", { | |
| month: "short", | |
| day: "numeric", | |
| hour: "numeric", | |
| minute: "2-digit", | |
| }).format(parsed) | |
| } | |
| export function titleCase(value) { | |
| if (!value) return "Unknown" | |
| return value | |
| .replace(/_/g, " ") | |
| .replace(/\b\w/g, (letter) => letter.toUpperCase()) | |
| } | |
| export function truncateText(value, maxLength = 140) { | |
| if (!value || value.length <= maxLength) return value | |
| return `${value.slice(0, maxLength - 1)}…` | |
| } | |