import { GLib, Variable } from "astal"

const DATE_FORMAT = "%Y-%m-%d"

export default function Date(props: { iconSide: "left" | "right" }) {
    const date = Variable<string>("").poll(1000, () =>
        GLib.DateTime.new_now_local().format(DATE_FORMAT)!)

    return <box className={`pill Date icon-${props.iconSide}`}>
        {props.iconSide == "left" && <label className="icon" label="" />}
        <label
            className="label"
            onDestroy={() => date.drop()}
            label={date()}
        />
        {props.iconSide == "right" && <label className="icon" label="" />}
    </box>
}
