Fix time formatting

This commit is contained in:
Torjus Håkestad 2021-04-10 13:46:53 +02:00
parent 38ef748dd0
commit b43193cfbb

View File

@ -9,23 +9,24 @@
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'; import { Component, Prop, Vue } from 'vue-property-decorator';
import { BvTableFieldArray } from 'bootstrap-vue'; import { BvTableFieldArray, BvTableFormatterCallback } from 'bootstrap-vue';
import { LoginAttempt } from '@/apiary/apiary'; import { LoginAttempt } from '@/apiary/apiary';
const timeFormatter: BvTableFormatterCallback = (value: string) => {
const d = new Date(value);
return `${d.getUTCHours}:${d.getUTCMinutes}:${d.getUTCSeconds}`;
};
@Component @Component
export default class AttemptList extends Vue { export default class AttemptList extends Vue {
@Prop() private items!: LoginAttempt[]; @Prop() private items!: LoginAttempt[];
attempts: LoginAttempt[]; attempts: LoginAttempt[];
fields: BvTableFieldArray = [ fields: BvTableFieldArray = [
{ {
key: 'date', key: 'date',
sortable: true, sortable: true,
formatter: (value: string): string => { formatter: timeFormatter,
const d = new Date(value);
return `${d.getUTCHours}:${d.getUTCMinutes}:${d.getUTCSeconds}`;
},
sortByFormatted: false, sortByFormatted: false,
}, },
{ {