fix chinese datapicker #105

This commit is contained in:
Alireza Ahmadi
2024-04-23 19:42:09 +02:00
parent ae7fa7285f
commit fa922291ea
3 changed files with 10 additions and 2 deletions
+1
View File
@@ -13,6 +13,7 @@
"chart.js": "^4.4.1", "chart.js": "^4.4.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"core-js": "^3.29.0", "core-js": "^3.29.0",
"moment": "^2.30.1",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"qrcode.vue": "^3.4.1", "qrcode.vue": "^3.4.1",
"roboto-fontface": "*", "roboto-fontface": "*",
+1
View File
@@ -14,6 +14,7 @@
"chart.js": "^4.4.1", "chart.js": "^4.4.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"core-js": "^3.29.0", "core-js": "^3.29.0",
"moment": "^2.30.1",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"qrcode.vue": "^3.4.1", "qrcode.vue": "^3.4.1",
"roboto-fontface": "*", "roboto-fontface": "*",
+8 -2
View File
@@ -10,7 +10,7 @@
<DatePicker <DatePicker
v-model="Input" v-model="Input"
@input="Input=$event" @input="Input=$event"
:locale="$i18n.locale" :locale="locale"
element="expiry" element="expiry"
compact-time compact-time
type="datetime"> type="datetime">
@@ -42,6 +42,8 @@
<script lang="ts"> <script lang="ts">
import DatePicker from 'vue3-persian-datetime-picker' import DatePicker from 'vue3-persian-datetime-picker'
import { i18n } from '@/locales' import { i18n } from '@/locales'
import 'moment/locale/zh-cn'
import 'moment/locale/zh-tw'
export default { export default {
props: ['expiry'], props: ['expiry'],
@@ -54,10 +56,14 @@ export default {
}, },
components: { DatePicker }, components: { DatePicker },
computed: { computed: {
locale() {
const l = i18n.global.locale.value
return l.replace('zh', 'zh-')
},
dateFormatted() { dateFormatted() {
if (this.expDate == 0) return i18n.global.t('unlimited') if (this.expDate == 0) return i18n.global.t('unlimited')
const date = new Date(this.expDate*1000) const date = new Date(this.expDate*1000)
return date.toLocaleString(i18n.global.locale.value) return date.toLocaleString(this.locale)
}, },
expDate() { expDate() {
return parseInt(this.expiry?? 0) return parseInt(this.expiry?? 0)