All checks were successful
continuous-integration/drone/push Build is passing
27 lines
517 B
Svelte
27 lines
517 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) => {
|
|
const d = dayjs(x, format).toDate();
|
|
if (d) {
|
|
date = d.toISOString();
|
|
}
|
|
};
|
|
|
|
$: input(date)
|
|
$: output(internal)
|
|
</script>
|
|
|
|
<input type="datetime-local" class={className} id={id} bind:value={internal}>
|