Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ yarn-error.log

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
34 changes: 27 additions & 7 deletions src/picker/VuePersianDatetimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<transition name="slideY">
<span :key="selectedDate.xYear()">
<slot name="header-year" v-bind="{ vm, selectedDate }">
{{ selectedDate.xYear() }}
{{ convertToLocaleNumber(selectedDate.xYear()) }}
</slot>
</span>
</transition>
Expand All @@ -94,7 +94,7 @@
<transition name="slideY">
<span :key="formattedDate">
<slot name="header-date" v-bind="{ vm, formattedDate }">
{{ formattedDate }}
{{ convertToLocaleNumber(formattedDate) }}
</slot>
</span>
</transition>
Expand Down Expand Up @@ -153,7 +153,9 @@
<slot name="month-name" v-bind="{ vm, date, color }">
<span
:style="{ 'border-color': color, color }"
v-text="date.xFormat('jMMMM jYYYY')"
v-text="
convertToLocaleNumber(date.xFormat('jMMMM jYYYY'))
"
/>
</slot>
</div>
Expand Down Expand Up @@ -208,7 +210,7 @@
/>
<span
:class="[prefix('day-text')]"
v-text="day.formatted"
v-text="convertToLocaleNumber(day.formatted)"
/>
</slot>
</template>
Expand Down Expand Up @@ -250,7 +252,7 @@
@click="selectYear(year)"
>
<slot name="year-item" v-bind="{ vm, year, color }">
{{ year.xFormat('jYYYY') }}
{{ convertToLocaleNumber(year.xFormat('jYYYY')) }}
</slot>
</div>
</div>
Expand Down Expand Up @@ -775,7 +777,13 @@ export default {
* @default true
* @version 2.1.6
*/
showNowBtn: { type: Boolean, default: true }
showNowBtn: { type: Boolean, default: true },
/**
* Convert to locale numbers or not
* @type Boolean
* @default false
*/
convertNumbers: { type: Boolean, default: false }
},
data() {
let defaultLocale = this.locale.split(',')[0]
Expand Down Expand Up @@ -1050,7 +1058,7 @@ export default {
let output = this.output.clone()
let format = this.selfDisplayFormat
if (/j\w/.test(format)) output.locale('fa')
return output.format(format)
return this.convertToLocaleNumber(output.format(format))
},
isDisableTime() {
return this.hasStep('t') && this.checkDisable('t', this.time)
Expand Down Expand Up @@ -1578,6 +1586,18 @@ export default {
}
}
return date.clone()
},
convertToLocaleNumber(value) {
if (this.convertNumbers && this.locale == 'fa') {
return `${value}`.replace(/\d+/g, function(digit) {
var ret = ''
for (var i = 0, len = digit.length; i < len; i++) {
ret += String.fromCharCode(digit.charCodeAt(i) + 1728)
}
return ret
})
}
return value
}
},
install(Vue, options) {
Expand Down