Skip to content

Commit

Permalink
feat(KennelLayout): add date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvanherwijnen committed Dec 17, 2024
1 parent 2b960a3 commit e03d505
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/app/src/pages/print/KennelLayout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<q-page class="page" :style="{ padding: '2cm' }">
<div class="row justify-center text-h6">
{{ selectedDate }}
{{ formatDate(selectedDate, { dateStyle: 'medium' }) }}
</div>
<div class="row" style="height: 150px">
<pet-chip
Expand Down Expand Up @@ -76,6 +76,7 @@ import { onMounted, reactive, ref, watch } from 'vue'
import { createUseTrpc } from '../../trpc.js'
import { extend, useMeta } from 'quasar'
import { onBeforeRouteUpdate, useRoute } from 'vue-router'
import { formatDate } from '../../tools.js'
const { useQuery } = await createUseTrpc()
Expand Down
26 changes: 26 additions & 0 deletions packages/app/src/tools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useQuasar } from 'quasar'

const dateFormatter = ({
date,
locale,
options
}: {
date: Date
locale: string
options?: Intl.DateTimeFormatOptions
}) =>
new Intl.DateTimeFormat(locale, { ...options, timeZone: 'UTC' }).format(date)

export const formatDate = (
date: string | null,
options?: Intl.DateTimeFormatOptions
) => {
const $q = useQuasar()
if (date)
return dateFormatter({
date: new Date(date),
locale: $q.lang.isoName,
options
})
return '-'
}

0 comments on commit e03d505

Please sign in to comment.