I need to share a date from a component in Svelte to several different components which are not children of the component. If they were all children I think I would use 'setContext' and 'getContext'. The best way I have come across is using a store, however when I use the store it does not appear to be saving a 'Date' but a 'Writable'. When I try to get values from the date it will not let me.
store.ts
import {writable} from "svelte/store"
export const date = writable<Date>(new Date())
component.ts
import { date } from "./store";
var hour = date.getHours();
let calendarDate = date.toISOString().split('T')[0]
I get an error "Property 'getHours' does not exist on type 'Writable'" and "Property 'toISOString' does not exist on type 'Writable'"
Is there a way to fix this or a better way to pass a date from one component to multiple using state, context, or something else I'm not aware of?
I tried using a store to save the date and was expecting the ability to be able to view and update the date in other components.