Skip to content

Commit

Permalink
Merge pull request #180 from CovOpen/DanielHabenicht-patch-2
Browse files Browse the repository at this point in the history
fix: return null instead of empty string
  • Loading branch information
DanielHabenicht authored Apr 19, 2021
2 parents b0e598e + 3755d5b commit 92affd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion covquestions-js/src/questionnaireEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ describe("questionnaireEngine", () => {
const engine = new QuestionnaireEngine(testQuestionnaire);
const result = engine.getVariables();

expect(result["converted_date"]).toEqual("");
expect(result["converted_date"]).toEqual(null);
});
});

Expand Down
4 changes: 2 additions & 2 deletions covquestions-js/src/questionnaireEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ export class QuestionnaireEngine {
function convertToDateString(
timestamp?: LogicExpression,
dateFormat?: LogicExpression
): string {
): string | null {
if (!timestamp || !dateFormat) {
return "";
return null;
}
const timestampInMilliseconds = parseInt(timestamp.toString()) * 1000;
return dayjs(timestampInMilliseconds).format(dateFormat.toString());
Expand Down

0 comments on commit 92affd4

Please sign in to comment.