This commit is contained in:
2026-07-16 14:32:20 +03:30
parent 62414cac88
commit 7cf11cd62e
2 changed files with 2 additions and 16 deletions
@@ -10,13 +10,12 @@ import locale from 'ant-design-vue/es/date-picker/locale/fa_IR'
import dayjs, { Dayjs } from 'dayjs'
import { omit } from 'lodash'
import { computed, useAttrs } from 'vue'
import { persianToEnglishDigits } from '@/utils/persianDigits'
interface Props {
value?: string | Dayjs
size?: string
format?: string
inputReadOnly?:boolean
inputReadOnly?: boolean
}
const attrs = useAttrs()
@@ -41,7 +40,7 @@ const _date = computed({
set: (val) => {
let temp: string | null = null
if (val) {
temp = persianToEnglishDigits(val.calendar('gregory').locale('en').format(props.format))
temp = val.calendar('gregory').locale('en').format(props.format)
}
emit('update:value', temp)
emit('onchange', temp)
-13
View File
@@ -1,13 +0,0 @@
const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩'
export function persianToEnglishDigits(value: string | number | null | undefined): string {
if (value == null) {
return ''
}
return String(value)
.replace(/[۰-۹]/g, (d) => String(PERSIAN_DIGITS.indexOf(d)))
.replace(/[٠-٩]/g, (d) => String(ARABIC_DIGITS.indexOf(d)))
.replace(/٫/g, '.')
}