Skip to content

Commit

Permalink
fix: date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed May 8, 2024
1 parent 6045c87 commit b341146
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions webui/src/lib/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const formatBytes = (bytes?: number | string) => {
const fmtHourMinute = new Intl.DateTimeFormat(undefined, {
hour: "2-digit",
minute: "2-digit",
day: "2-digit",
month: "2-digit",
year: "numeric",
});

const timezoneOffsetMs = new Date().getTimezoneOffset() * 60 * 1000;
Expand All @@ -28,9 +31,8 @@ export const formatTime = (time: number | string | Date) => {
} else if (time instanceof Date) {
time = time.getTime();
}
const d = new Date();
d.setTime(time - timezoneOffsetMs);
return d.toISOString().substring(0, 10) + " at " + fmtHourMinute.format(d);
const d = new Date(time);
return fmtHourMinute.format(d);
};

export const localISOTime = (time: number | string | Date) => {
Expand Down

0 comments on commit b341146

Please sign in to comment.