Skip to content

Commit

Permalink
fix chinese datapicker #105
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Apr 23, 2024
1 parent ae7fa72 commit fa92229
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"chart.js": "^4.4.1",
"clipboard": "^2.0.11",
"core-js": "^3.29.0",
"moment": "^2.30.1",
"pinia": "^2.1.7",
"qrcode.vue": "^3.4.1",
"roboto-fontface": "*",
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/DateTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DatePicker
v-model="Input"
@input="Input=$event"
:locale="$i18n.locale"
:locale="locale"
element="expiry"
compact-time
type="datetime">
Expand Down Expand Up @@ -42,6 +42,8 @@
<script lang="ts">
import DatePicker from 'vue3-persian-datetime-picker'
import { i18n } from '@/locales'
import 'moment/locale/zh-cn'
import 'moment/locale/zh-tw'
export default {
props: ['expiry'],
Expand All @@ -54,10 +56,14 @@ export default {
},
components: { DatePicker },
computed: {
locale() {
const l = i18n.global.locale.value
return l.replace('zh', 'zh-')
},
dateFormatted() {
if (this.expDate == 0) return i18n.global.t('unlimited')
const date = new Date(this.expDate*1000)
return date.toLocaleString(i18n.global.locale.value)
return date.toLocaleString(this.locale)
},
expDate() {
return parseInt(this.expiry?? 0)
Expand Down

0 comments on commit fa92229

Please sign in to comment.