22 lines
465 B
Svelte
22 lines
465 B
Svelte
|
<script>
|
||
|
import dayjs from 'dayjs';
|
||
|
|
||
|
export let format = 'YYYY-MM-DD HH:mm';
|
||
|
export let date = new Date();
|
||
|
|
||
|
let className = '';
|
||
|
export { className as class };
|
||
|
|
||
|
export let id = null;
|
||
|
|
||
|
let internal;
|
||
|
|
||
|
const input = (x) => (internal = dayjs(x).format(format));
|
||
|
const output = (x) => (date = dayjs(x, format).toDate().toISOString());
|
||
|
|
||
|
$: input(date)
|
||
|
$: output(internal)
|
||
|
</script>
|
||
|
|
||
|
<input type="datetime-local" class={className} id={id} bind:value={internal}>
|