Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transformCurrYearName optional prop function to transform format (for year on calendar header) #834

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Datepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
:mondayFirst="mondayFirst"
:dayCellContent="dayCellContent"
:use-utc="useUtc"
:transformCurrYearName="transformCurrYearName"
@changedMonth="handleChangedMonthFromDayPicker"
@selectDate="selectDate"
@showMonthCalendar="showMonthCalendar"
Expand Down Expand Up @@ -153,7 +154,8 @@ export default {
maximumView: {
type: String,
default: 'year'
}
},
transformCurrYearName: { type: Function }
},
data () {
const startDate = this.openDate ? new Date(this.openDate) : new Date()
Expand Down
6 changes: 4 additions & 2 deletions src/components/PickerDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default {
translation: Object,
isRtl: Boolean,
mondayFirst: Boolean,
useUtc: Boolean
useUtc: Boolean,
transformCurrYearName: Function
},
data () {
const constructedDateUtils = makeDateUtils(this.useUtc)
Expand Down Expand Up @@ -126,7 +127,8 @@ export default {
*/
currYearName () {
const yearSuffix = this.translation.yearSuffix
return `${this.utils.getFullYear(this.pageDate)}${yearSuffix}`
const fy = this.utils.getFullYear(this.pageDate)
return this.transformCurrYearName ? this.transformCurrYearName(fy) : `${fy}${yearSuffix}`
},
/**
* Is this translation using year/month/day format?
Expand Down