ora/src/dashboard/components/DateInput.svelte

25 lines
449 B
Svelte
Raw Normal View History

2020-09-19 01:16:43 +02:00
<script>
import dayjs from 'dayjs'
const format = 'YYYY-MM-DD'
export let name = ''
export let date = new Date()
let internal
const input = (x) => (internal = dayjs(x).format(format))
const output = (x) => (date = dayjs(x, format).toDate())
$: input(date)
$: output(internal)
</script>
2021-11-22 01:58:09 +01:00
<input class="form-input input-sm" type="date" bind:value={internal} {name} />
2020-09-19 01:30:42 +02:00
<style>
input {
2020-10-12 00:26:36 +02:00
width: 7rem !important;
2020-09-19 01:30:42 +02:00
}
</style>