//#region src/utils/date.ts
/**
* Checks if a date string is in PostgreSQL timestamp format and normalizes it to ISO 8601
* PostgreSQL format: "2025-11-07 21:48:24.858" or "2025-11-07 21:48:24"
* ISO 8601 format: "2025-11-07T21:48:24.858Z"
*/
function normalizeDateString(dateString) {
	if (typeof dateString !== "string") return dateString;
	if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d{1,3})?$/.test(dateString)) return `${dateString.replace(" ", "T")}Z`;
	return dateString;
}
/**
* Converts a date value (string or Date) to an ISO 8601 date-time string
* Ensures consistent string output for API responses and database operations
*/
function toISODateString(dateValue) {
	if (typeof dateValue === "string") {
		const normalized = normalizeDateString(dateValue);
		return typeof normalized === "string" ? normalized : normalized.toISOString();
	}
	return dateValue.toISOString();
}

//#endregion
export { normalizeDateString, toISODateString };