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:
hamed
2026-07-27 19:37:44 +03:30
parent 2963e2ac74
commit b423a0ae4d
21 changed files with 267 additions and 57 deletions
+8 -2
View File
@@ -312,6 +312,7 @@ Get all date overrides for a doctor.
"uuid": "...",
"doctor_uuid": "...",
"date": 1718476800,
"date_string": "2024-06-15",
"active": false,
"reason": "تعطیل خاص",
"custom_slots": [],
@@ -322,7 +323,7 @@ Get all date overrides for a doctor.
}
```
> `date` is a Unix timestamp. `active: false` = entire day blocked. `active: true` with `custom_slots` = custom session schedule.
> `date` is a Unix timestamp at **server-local midnight** (`Asia/Tehran`); `date_string` is the same day as `Y-m-d` and is what clients must render — converting the timestamp in a browser with `toISOString()` (UTC) shifts it one day back. `active: false` = entire day blocked. `active: true` with `custom_slots` = custom session schedule.
---
@@ -387,6 +388,7 @@ Create a date override.
"uuid": "override-uuid-...",
"doctor_uuid": "...",
"date": 1718476800,
"date_string": "2024-06-15",
"active": false,
"reason": "تعطیل رسمی",
"custom_slots": [],
@@ -490,6 +492,8 @@ Get all holidays for a doctor.
"doctor_uuid": "...",
"start_date": 1719792000,
"end_date": 1720656000,
"start_date_string": "2024-07-01",
"end_date_string": "2024-07-11",
"reason": "تعطیلات تابستانی",
"active": true,
"created_at": 1717000000
@@ -499,7 +503,7 @@ Get all holidays for a doctor.
}
```
> `start_date` and `end_date` are Unix timestamps. Holidays take **highest priority** — they block the day even if a date override exists.
> `start_date` / `end_date` are Unix timestamps at **server-local midnight** (`Asia/Tehran`); `start_date_string` / `end_date_string` carry the same days as `Y-m-d` and are what clients must render (UTC conversion in the browser shifts them one day back). Holidays take **highest priority** — they block the day even if a date override exists.
---
@@ -536,6 +540,8 @@ Create a holiday range.
"doctor_uuid": "...",
"start_date": 1719792000,
"end_date": 1720656000,
"start_date_string": "2024-07-01",
"end_date_string": "2024-07-11",
"reason": "تعطیلات تابستانی",
"active": true,
"created_at": 1717000000