refactor: normalize date handling to Tehran timezone
- Updated date handling in BlogSeoFields and ScheduleSection to use Tehran timezone utilities for consistency. - Introduced `toTehranClockTime`, `tehranWallClockToUnix`, and `todayIso` functions for accurate date representation. - Modified various components to utilize these new utilities, ensuring that date strings are correctly formatted and timestamps are accurately converted. - Enhanced API documentation to clarify the handling of date fields, emphasizing the importance of server-local midnight. - Added tests to verify that date overrides and holidays maintain the correct day without shifting due to timezone discrepancies.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline';
|
||||
import { todayIso } from '../../lib/utils';
|
||||
|
||||
interface Props {
|
||||
value: string; // YYYY-MM-DD Gregorian
|
||||
@@ -70,7 +71,8 @@ const JALALI_MONTHS = ['فروردین','اردیبهشت','خرداد','تیر'
|
||||
export default function PersianCalendar({ value, onChange, onClose, enableYearPicker = false }: Props) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
const todayGreg = new Date().toISOString().slice(0, 10);
|
||||
// «امروز» به وقت ایران، نه UTC: `toISOString` بعد از ۲۰:۳۰ فردا را امروز نشان میداد.
|
||||
const todayGreg = todayIso();
|
||||
const todayJ = toJalali(new Date(todayGreg + 'T12:00:00'));
|
||||
const valueJ = value ? toJalali(new Date(value + 'T12:00:00')) : todayJ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user