diff --git a/src/filters.js b/src/filters.js index 871f58ab1..9467b04d6 100644 --- a/src/filters.js +++ b/src/filters.js @@ -3,6 +3,12 @@ import { APPLICATION_STATUS } from '@/helpers/constants'; const formatDate = (value, type) => { if (value) { const objDate = new Date(Date.parse(value)); + + // If not a valid date + if (!(objDate instanceof Date)){ + return null; + } + switch (type) { case 'month': return `${objDate.toLocaleString('en-GB', { month: 'long' })} ${objDate.getUTCFullYear()}`; diff --git a/src/views/Exercises/Applications/Application.vue b/src/views/Exercises/Applications/Application.vue index de0655eda..9e3874fdf 100644 --- a/src/views/Exercises/Applications/Application.vue +++ b/src/views/Exercises/Applications/Application.vue @@ -76,7 +76,7 @@

- {{ application.createdAt | showAlternative("Unknown") | formatDate }} + {{ application.createdAt | formatDate | showAlternative("Unknown")}}

@@ -88,7 +88,7 @@ v-if="isApplied" class="govuk-heading-m govuk-!-margin-bottom-0" > - {{ application.createdAt | showAlternative("Unknown") | formatDate }} + {{ application.appliedAt | formatDate | showAlternative("Unknown") }}