Skip to content

Commit

Permalink
chore(papi): [sc-35270] Update date fields for consistent format
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-summer committed Aug 9, 2022
1 parent 533ada8 commit 93e08bf
Show file tree
Hide file tree
Showing 2 changed files with 269 additions and 275 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,18 @@ const formatRecords = (recs, columns, hydrate, formatOptions) => {

// Format record value based on its value, the database column's typeName and the formatting options
const formatRecordValue = (value, typeName, formatOptions) => {
const standardizedTypeName = typeName ? typeName.toUpperCase() : typeName

if (
formatOptions &&
formatOptions.deserializeDate &&
['DATE', 'DATETIME', 'TIMESTAMP', 'TIMESTAMPTZ', 'TIMESTAMP WITH TIME ZONE'].includes(typeName.toUpperCase())
['DATE', 'DATETIME', 'TIMESTAMP', 'TIMESTAMPTZ', 'TIMESTAMP WITH TIME ZONE'].includes(standardizedTypeName)
) {
return formatFromTimeStamp(
value,
(formatOptions && formatOptions.treatAsLocalDate) || typeName === 'TIMESTAMP WITH TIME ZONE'
(formatOptions && formatOptions.treatAsLocalDate) || standardizedTypeName === 'TIMESTAMP WITH TIME ZONE'
)
} else if (typeName === 'JSON') {
} else if (standardizedTypeName === 'JSON') {
return JSON.parse(value)
} else {
return value
Expand Down
Loading

0 comments on commit 93e08bf

Please sign in to comment.