RavindranadhM's picture
Deploy manufacturing monitoring system
201b13c verified
Raw
History Blame Contribute Delete
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)}…`
}