feat(shared): zod şemaları, Türkçe arama ve TL/tarih biçimleri

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 01:35:10 +03:00
parent c875847b65
commit 4dbd2eb441
11 changed files with 504 additions and 3 deletions
+42
View File
@@ -0,0 +1,42 @@
/**
* Görüntüleme biçimleri (tr-TR, Europe/Istanbul). Sunucu ve istemci aynı sonucu üretir
* çünkü yerel ayar ve saat dilimi her zaman açıkça verilir (hydration uyumsuzluğu olmaz).
*/
export const LOCALE = "tr-TR";
export const TIME_ZONE = "Europe/Istanbul";
const moneyFmt = new Intl.NumberFormat(LOCALE, { style: "currency", currency: "TRY" });
/** Kuruş cinsinden tamsayı tutarı TL olarak biçimlendirir: 125050 → "₺1.250,50". */
export function formatMoney(amountMinor: number): string {
if (!Number.isSafeInteger(amountMinor)) {
throw new TypeError(`amountMinor tamsayı olmalı: ${amountMinor}`);
}
return moneyFmt.format(amountMinor / 100);
}
const dateFmt = new Intl.DateTimeFormat(LOCALE, {
timeZone: TIME_ZONE,
day: "2-digit",
month: "2-digit",
year: "numeric",
});
const dateTimeFmt = new Intl.DateTimeFormat(LOCALE, {
timeZone: TIME_ZONE,
day: "2-digit",
month: "2-digit",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
});
/** UTC tarihi İstanbul saatine göre "dd.MM.yyyy" biçiminde gösterir. */
export function formatDate(date: Date | string): string {
return dateFmt.format(new Date(date));
}
/** UTC tarihi İstanbul saatine göre "dd.MM.yyyy HH:mm" biçiminde gösterir. */
export function formatDateTime(date: Date | string): string {
return dateTimeFmt.format(new Date(date));
}