improve update date format

This commit is contained in:
mbecker20
2024-06-04 04:36:55 -07:00
parent 6aa5b5faae
commit b44e57bbf6
2 changed files with 31 additions and 2 deletions

View File

@@ -268,7 +268,7 @@ export const NewResource = ({
enabled={!!name}
onOpenChange={() => setName("")}
>
<div className="grid md:grid-cols-2">
<div className="grid md:grid-cols-2 items-center">
{type} Name
<Input
placeholder={`${type_display}-name`}

View File

@@ -3,11 +3,40 @@ import { Types } from "@monitor/client";
export const fmt_date = (d: Date) => {
const hours = d.getHours();
const minutes = d.getMinutes();
return `${d.getDate()}/${d.getMonth() + 1} @ ${
return `${fmt_month(d.getMonth())} ${d.getDate()} @ ${
hours > 9 ? hours : "0" + hours
}:${minutes > 9 ? minutes : "0" + minutes}`;
};
const fmt_month = (month: number) => {
switch (month) {
case 0:
return "Jan";
case 1:
return "Feb";
case 2:
return "Mar";
case 3:
return "Apr";
case 4:
return "May";
case 5:
return "Jun";
case 6:
return "Jul";
case 7:
return "Aug";
case 8:
return "Sep";
case 9:
return "Oct";
case 10:
return "Nov";
case 11:
return "Dec";
}
};
export const fmt_date_with_minutes = (d: Date) => {
// return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;
return d.toLocaleString();