Files
PasswordManager/public/utils.js
RochesterX 9e88712e9f Search
2025-11-18 21:16:35 -05:00

42 lines
892 B
JavaScript

export function formatText(text) {
if (text == null) return "—";
if (typeof(text) === "string") {
return text;
}
else {
return "Unknown format";
}
}
export function formatSalary(text) {
if (text == null) return "—";
try {
var millions = (parseInt(text, 10) / 1000000).toFixed(2);
return `$${millions} million`;
} catch (e) {
return "Unknown format"
}
}
export function formatDate(date) {
if (date == null) return "—";
if (typeof(date) === "string") {
return date.split("T")[0];
}
else {
return "Unknown format";
}
}
export function formatDateTime(date) {
if (date == null) return "—";
if (typeof(date) === "string") {
return date.split("T")[0] + " at " + date.split("T")[1].split(".")[0];
}
else {
return "Unknown format";
}
}