Search
This commit is contained in:
41
public/utils.js
Normal file
41
public/utils.js
Normal file
@@ -0,0 +1,41 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user