Removing custom date formatting

This commit is contained in:
Michaela Brydon 2023-10-16 16:14:25 -04:00
parent c6a493a973
commit 4f963d53e7
2 changed files with 7 additions and 20 deletions

View file

@ -163,7 +163,7 @@ describe('duplicateCheck.vue', () => {
main: mainInitialState main: mainInitialState
} }
})]; })];
const expectedSubtext = '11/01/2004'; const expectedSubtext = '11/1/2004';
const wrapper = shallowMount(duplicateCheck, mountOptions); const wrapper = shallowMount(duplicateCheck, mountOptions);
@ -189,7 +189,7 @@ describe('duplicateCheck.vue', () => {
vehicleYear: getRandomString(6, 6), vehicleYear: getRandomString(6, 6),
vehicleMake: getRandomString(6, 6), vehicleMake: getRandomString(6, 6),
vehicleModel: null, vehicleModel: null,
responseDate: '1999-02-30T01:12:34', responseDate: '1999-01-15T01:12:34',
referralNumber referralNumber
} }
] ]
@ -200,7 +200,7 @@ describe('duplicateCheck.vue', () => {
main: mainInitialState main: mainInitialState
} }
})]; })];
const expectedSubtext = '2/30/1999'; const expectedSubtext = '1/15/1999';
const wrapper = shallowMount(duplicateCheck, mountOptions); const wrapper = shallowMount(duplicateCheck, mountOptions);
@ -238,7 +238,7 @@ describe('duplicateCheck.vue', () => {
} }
})]; })];
const expectedVehicle = 'Year Make Model'; const expectedVehicle = 'Year Make Model';
const expectedDate = '3/01/2018'; const expectedDate = '3/1/2018';
const wrapper = shallowMount(duplicateCheck, mountOptions); const wrapper = shallowMount(duplicateCheck, mountOptions);

View file

@ -105,9 +105,10 @@ export default {
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}` ? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
: null; : null;
const dateOfLoss = o.responseDate == null ? '' : new Date(o.responseDate).toLocaleDateString();
const subtext = vehicle && o.responseDate const subtext = vehicle && o.responseDate
? `${vehicle}, ${this.getDateMinusTime(o.responseDate)}` ? `${vehicle}, ${dateOfLoss}`
: (vehicle ?? '').concat(this.getDateMinusTime(o.responseDate ?? '')); : (vehicle ?? '').concat(dateOfLoss);
return { return {
Text: duplicateOrderText, Text: duplicateOrderText,
@ -159,20 +160,6 @@ export default {
this.$route this.$route
); );
} }
},
/**
* @param date date string in YYYY-MM-DDTHH:mm:ss format.
* @summary Converts a date string from YYYY-MM-DDTHH:mm:ss to M-DD-YYYY
*/
getDateMinusTime(date) {
if (!date) { return ''; }
const yyyyMmDd = date.substring(0, 10).split('-');
const year = yyyyMmDd[0];
const month = yyyyMmDd[1][0] === '0'
? yyyyMmDd[1][1]
: yyyyMmDd[1];
const day = yyyyMmDd[2];
return `${month}/${day}/${year}`;
} }
} }
}; };