@@ -0,0 +1,17 @@
|
||||
import { toJalaali } from '@/utils/date-utils'
|
||||
|
||||
const FA_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
|
||||
|
||||
export const toFaDigits = (value) => String(value ?? '').replace(/\d/g, (d) => FA_DIGITS[d])
|
||||
|
||||
/**
|
||||
* Formats an ISO timestamp as a compact Jalaali meta line — "۱۴۰۰/۷/۱۹, ۸:۳۰".
|
||||
* Reads the wall-clock date/time from the string as-is (no timezone shift), so
|
||||
* the value mirrors what the backend recorded.
|
||||
*/
|
||||
export const formatJalaaliMeta = (iso) => {
|
||||
const match = String(iso ?? '').match(/^(\d{4})-(\d{2})-(\d{2})[\sT](\d{2}):(\d{2})/)
|
||||
if (!match) return ''
|
||||
const { jy, jm, jd } = toJalaali(Number(match[1]), Number(match[2]), Number(match[3]))
|
||||
return toFaDigits(`${jy}/${jm}/${jd}, ${Number(match[4])}:${match[5]}`)
|
||||
}
|
||||
Reference in New Issue
Block a user