YARA-1258

This commit is contained in:
SepehrYahyaee
2026-09-12 14:23:23 +03:30
parent 9e51fdcdaf
commit 7fd60df1d6
5 changed files with 300 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
import { IRAN_TIMEZONE } from "./iran-datetime";
/**
* Converts an ISO date string or Date to Jalali (Persian) date and time.
* @param input - ISO date string (e.g. 2026-02-08T13:51:20.747+00:00) or Date
@@ -70,6 +72,7 @@ export function jalaliToGregorianDate(
*/
export function toJalaliDate(d: Date): string {
const persianDate = d.toLocaleDateString("fa-IR", {
timeZone: IRAN_TIMEZONE,
year: "numeric",
month: "2-digit",
day: "2-digit",
@@ -81,9 +84,12 @@ export function toJalaliDate(d: Date): string {
* Converts a Date to 24h time string (e.g. 13:37).
*/
export function toJalaliTime(d: Date): string {
const hours = d.getHours().toString().padStart(2, "0");
const minutes = d.getMinutes().toString().padStart(2, "0");
return `${hours}:${minutes}`;
return new Intl.DateTimeFormat("en-GB", {
timeZone: IRAN_TIMEZONE,
hour: "2-digit",
minute: "2-digit",
hourCycle: "h23",
}).format(d);
}
/**