import { Variable, GLib } from "astal";
import { Widget } from "astal/gtk4";
type Props = {
format: string,
interval?: number
} & Widget.LabelProps;
export default function DateTime({ format, interval, ...props }: Props) {
const shouldPoll = typeof interval === "number" && interval >= 1;
const currentTime = () => {
const dateTime = GLib.DateTime.new_now_local();
return dateTime.format(format)!;
}
if (shouldPoll) {
const pollTime = new Variable(currentTime()).poll(interval || 1000, currentTime);
return
} else {
const time = new Variable(currentTime())
return
}
}