Skip to content

Commit

Permalink
Fix Localhost Date Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
demariadaniel committed Feb 9, 2024
1 parent 4f5ddfd commit a8844bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions global/utils/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ export const asEnum = (obj, { name = 'enum' } = {}) =>

const dateFormat = 'yyyy-MM-dd';
export const displayDate = (date: string | Date) => {
const jsDate = typeof date === 'string' ? new Date(date) : date;
// Dates stored as UTC need to be converted to milliseconds; breaks on localhost
const jsDate =
typeof date === 'string'
? parseInt(date)
? new Date(parseInt(date) * 1000)
: new Date(date)
: date;

return formatDate(jsDate, dateFormat);
};

Expand Down Expand Up @@ -84,7 +91,7 @@ export const exportToTsv = <Data extends { [k: string]: string | number }>(
include: includeKeys = allKeys,
order = allKeys,
fileName = 'data.tsv',
headerDisplays = allKeys.reduce<typeof options['headerDisplays']>(
headerDisplays = allKeys.reduce<(typeof options)['headerDisplays']>(
(acc, key) => ({
...acc,
[key]: options.headerDisplays ? options.headerDisplays[key] : key,
Expand Down

0 comments on commit a8844bd

Please sign in to comment.