Initial commit: AI platform app (server, views, lib, data, deploy docs)
Made-with: Cursor
This commit is contained in:
20
lib/meeting-date-format.js
Normal file
20
lib/meeting-date-format.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* PostgreSQL DATE 또는 날짜 전용 값을 YYYY-MM-DD로 직렬화.
|
||||
* `new Date(x).toISOString().slice(0, 10)`은 UTC 기준이라
|
||||
* 서버/클라이언트 TZ가 한국 등일 때 **하루 전 날짜**로 잘릴 수 있음.
|
||||
*/
|
||||
function formatMeetingDateOnly(val) {
|
||||
if (val == null || val === "") return null;
|
||||
if (typeof val === "string") {
|
||||
const s = val.trim().slice(0, 10);
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s;
|
||||
}
|
||||
const d = val instanceof Date ? val : new Date(val);
|
||||
if (Number.isNaN(d.getTime())) return null;
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
return `${y}-${m}-${day}`;
|
||||
}
|
||||
|
||||
module.exports = { formatMeetingDateOnly };
|
||||
Reference in New Issue
Block a user