Skip to content

Commit 6ab098d

Browse files
authored
Merge pull request #644 from bcgov/ccfri-4584-temporal-issues
fix: MDY format messing up submission dates
2 parents 14951ff + 1ef8dc3 commit 6ab098d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

frontend/src/components/SubmissionHistory.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { useDocumentStore } from '@/store/document.js';
5757
import alertMixin from '@/mixins/alertMixin.js';
5858
import { PATHS, ApiRoutes } from '@/utils/constants.js';
5959
import { formatFiscalYearName } from '@/utils/format';
60+
import { mdyToIso } from '@/utils/formatTime';
6061
6162
export default {
6263
components: { NavButton },
@@ -124,7 +125,11 @@ export default {
124125
getSubmissionDateString(date) {
125126
if (date) {
126127
// date display format: YYYY/MM/DD
127-
return new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: '2-digit', day: '2-digit' });
128+
return new Date(mdyToIso(date)).toLocaleDateString(undefined, {
129+
year: 'numeric',
130+
month: '2-digit',
131+
day: '2-digit',
132+
});
128133
}
129134
return '- - - -';
130135
},

frontend/src/utils/formatTime.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* Formats the DD/MM/YY HH:mm format from dynamics into an ISO
3+
* friendly string of YYYY-MM-DDTHH:mm:ss.sssZ
4+
*/
5+
export function mdyToIso(dateTimeString) {
6+
const [date, time] = dateTimeString.split(' ');
7+
const [month, day, year] = date.split('/');
8+
return `${year}-${month}-${day}T${time}.000Z`;
9+
}
10+
111
export default function formatTime(v) {
212
let hour = v.split(':')[0];
313
hour = parseInt(hour);

0 commit comments

Comments
 (0)