test: pin time on Chromatic
This commit is contained in:
parent
b346b99527
commit
b2131592f2
|
@ -18,10 +18,12 @@ const props = withDefaults(defineProps<{
|
||||||
showS?: boolean;
|
showS?: boolean;
|
||||||
showMs?: boolean;
|
showMs?: boolean;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
|
now?: () => Date;
|
||||||
}>(), {
|
}>(), {
|
||||||
showS: true,
|
showS: true,
|
||||||
showMs: false,
|
showMs: false,
|
||||||
offset: 0 - new Date().getTimezoneOffset(),
|
offset: 0 - new Date().getTimezoneOffset(),
|
||||||
|
now: () => new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const hh = ref('');
|
const hh = ref('');
|
||||||
|
@ -39,9 +41,9 @@ watch(showColon, (v) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const tick = () => {
|
const tick = (): void => {
|
||||||
const now = new Date();
|
const now = props.now();
|
||||||
now.setMinutes(now.getMinutes() + (new Date().getTimezoneOffset() + props.offset));
|
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + props.offset);
|
||||||
hh.value = now.getHours().toString().padStart(2, '0');
|
hh.value = now.getHours().toString().padStart(2, '0');
|
||||||
mm.value = now.getMinutes().toString().padStart(2, '0');
|
mm.value = now.getMinutes().toString().padStart(2, '0');
|
||||||
ss.value = now.getSeconds().toString().padStart(2, '0');
|
ss.value = now.getSeconds().toString().padStart(2, '0');
|
||||||
|
@ -57,7 +59,7 @@ onMounted(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
defaultIdleRender.remove(tick);
|
defaultIdleRender.delete(tick);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue