import type { CalendarDate } from "@internationalized/date";

export function getJustDateString(d: Date): string {
	return d.toISOString().split("T")[0];
}

export function makeDateStringISO(ds: string): string {
	if (ds.includes("T")) {
		return `${ds.split("T")[0]}T00:00:00.000Z`;
	}
	return `${ds}T00:00:00.000Z`;
}

export function parseCalDateToDateString(v: CalendarDate) {
	let month: string | number = v.month;
	if (month < 10) {
		month = `0${month}`;
	}
	let day: string | number = v.day;
	if (day < 10) {
		day = `0${day}`;
	}
	return `${v.year}-${month}-${day}`;
}
