Skip to content

Commit

Permalink
fixed billing dates appearing incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Jun 16, 2024
1 parent aebfffa commit 5b79b37
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src-frontend/src/mixins/formatMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ export function formatCsvList(list: Array<string>) {
});
}

export function formatDate(date: Date, time = true) {
if (time) return dayjs(date).local().format('D MMM YYYY, h:mm a');
return dayjs(date).local().format('D MMM YYYY');
export function formatDate(date: Date | number, time = true) {
let parsedDate = date;
// if it's earlier than 2000 it's clearly not been scaled to js time which is stored in milliseconds
if (typeof date === 'number' && date < 9439200000) {
parsedDate = date * 1000;
}
if (time) return dayjs(parsedDate).local().format('D MMM YYYY, h:mm a');
return dayjs(parsedDate).local().format('D MMM YYYY');
}

export function formatDateSimple(date: Date, time = true) {
Expand Down

0 comments on commit 5b79b37

Please sign in to comment.