Skip to content

Commit

Permalink
Fix handling of blank inputs and delims
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Dec 21, 2023
1 parent c49898e commit f12a3a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
{ "displayName" : "DD", "value" : "DD" },
{ "displayName" : "Thurs DD", "value" : "Thurs DD" },
{ "displayName" : "Thursday DD", "value" : "Thursday DD" },
{ "displayName" : "(blank)", "value" : "blank" }
{ "displayName" : "(blank)", "value" : "(blank)" }
]
}
},
Expand All @@ -325,7 +325,7 @@
{ "displayName" : "MM", "value" : "MM" },
{ "displayName" : "Mon", "value" : "Mon" },
{ "displayName" : "Month", "value" : "Month" },
{ "displayName" : "(blank)", "value" : "blank" }
{ "displayName" : "(blank)", "value" : "(blank)" }
]
}
},
Expand All @@ -335,7 +335,7 @@
"enumeration" : [
{ "displayName" : "YYYY", "value" : "YYYY" },
{ "displayName" : "YY", "value" : "YY" },
{ "displayName" : "(blank)", "value" : "blank" }
{ "displayName" : "(blank)", "value" : "(blank)" }
]
}
},
Expand Down
8 changes: 4 additions & 4 deletions src/Functions/dateSettingsToFormatOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ const weekdayDateMap: Record<string, "long" | "short"> = {
"DD" : null,
"Thurs DD" : "short",
"Thursday DD" : "long",
"blank" : null
"(blank)" : null
}

const monthDateMap: Record<string, "2-digit" | "short" | "long"> = {
"MM" : "2-digit",
"Mon" : "short",
"Month" : "long",
"blank" : null
"(blank)" : null
}

const yearDateMap: Record<string, "numeric" | "2-digit"> = {
"YYYY" : "numeric",
"YY" : "2-digit",
"blank" : null
"(blank)" : null
}

const dayDateMap = {
"DD" : "2-digit",
"Thurs DD" : "2-digit",
"Thursday DD" : "2-digit",
"blank" : null
"(blank)" : null
}

const dateOptionsLookup = {
Expand Down
7 changes: 5 additions & 2 deletions src/Functions/extractDataColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ function extractKeys(inputView: DataViewCategorical, inputSettings: defaultSetti
return null
}
const dateParts = datePartsToRecord(formatter.formatToParts(<Date>value))
const quarter: string = inputDates.quarters?.[idx] ?? ""
return `${dateParts.weekday} ${dateParts.day}${delim}${dateParts.month}${delim}${quarter}${delim}${dateParts.year}`
const datePartStrings: string[] = [dateParts.weekday + " " + dateParts.day,
dateParts.month,
inputDates.quarters?.[idx] ?? "",
dateParts.year];
return datePartStrings.filter(d => String(d).trim()).join(delim)
})
}

Expand Down

0 comments on commit f12a3a2

Please sign in to comment.