From 7c85f298a0f6d0300acf8ebaad344494158cf019 Mon Sep 17 00:00:00 2001 From: Prasidha Karki Date: Thu, 6 Aug 2020 13:05:03 +0545 Subject: [PATCH] year next previous --- src/nepali_date_picker/calendar.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/nepali_date_picker/calendar.js b/src/nepali_date_picker/calendar.js index daae33b..2362297 100644 --- a/src/nepali_date_picker/calendar.js +++ b/src/nepali_date_picker/calendar.js @@ -120,6 +120,16 @@ class NepaliCalendar extends Component { }) this.setCalendarData(bsYear, bsMonth, bsDate) } + renderBSYear=(bsYear)=>{ + let calendarDataBS = this.state.calendarDataBS; + var prevMonth = (calendarDataBS.month); + var prevYear = bsYear; + var prevDate = calendarDataBS.dayValue; + if (prevYear < calendarData.minBsYear || prevYear > calendarData.maxBsYear) { + return null; + } + this.setCalendarData(prevYear, prevMonth, prevDate) + } setCalendarData = (bsYear, bsMonth, bsDate) => { let _data = calendarFunctions.getBsMonthInfoByBsDate(bsYear, bsMonth, bsDate, this.props.dateFormat || "%D, %M %d, %y"); @@ -160,7 +170,11 @@ class NepaliCalendar extends Component {
-
❮❮
+
{ + this.renderBSYear(_calendarData.year-1) + }} + className='prev-year hand-cursor'>❮❮
{ this.renderPreviousBSMonth() }} className='prev-month hand-cursor'>❮
@@ -173,7 +187,9 @@ class NepaliCalendar extends Component {
{ this.renderNextBSMonth() }} className='next-month hand-cursor'>❯
-
❯❯
+
{ + this.renderBSYear(_calendarData.year+1) + }} title="Next Year" className='next-year hand-cursor'>❯❯
@@ -211,7 +227,7 @@ class NepaliCalendar extends Component { isSelected=true } - if(todayDataBS.date==value_item&&todayDataBS.month==_calendarData.month){ + if(todayDataBS.date==value_item&&todayDataBS.month==_calendarData.month&&todayDataBS.year==_calendarData.year){ isToday=true }