export function parseRupiahInput(value: string): number {
	const digits = value.replace(/\D/g, '');
	return digits ? Number(digits) : 0;
}

export function formatRupiahInput(value: number): string {
	if (!value) return '';
	return new Intl.NumberFormat('id-ID').format(value);
}

export function getTodayDateString(): string {
	const now = new Date();
	const year = now.getFullYear();
	const month = String(now.getMonth() + 1).padStart(2, '0');
	const day = String(now.getDate()).padStart(2, '0');
	return `${year}-${month}-${day}`;
}

export function isValidDateString(value: string): boolean {
	if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
	const date = new Date(value);
	return !Number.isNaN(date.getTime());
}
