Skip to content

Commit

Permalink
Merge pull request #1 from DogusTeknoloji/feature/fix-current-year-issue
Browse files Browse the repository at this point in the history
Fix check current year between min/max date
  • Loading branch information
BerkkanB authored Oct 13, 2021
2 parents 47e7955 + 1caecdd commit f4eabea
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fun ComposeCalendar(
if (showOnlyMonth && showOnlyYear) {
throw IllegalStateException("'showOnlyMonth' and 'showOnlyYear' states cannot be true at the same time")
} else {

var minYear = 1970
var minMonth = 0
var maxYear = 2100
Expand All @@ -54,7 +55,14 @@ fun ComposeCalendar(

val calendar = Calendar.getInstance(locale)
val currentMonth = calendar.get(Calendar.MONTH)
val currentYear = calendar.get(Calendar.YEAR)
var currentYear = calendar.get(Calendar.YEAR)

if (minYear>currentYear){
currentYear = minYear
}
if (maxYear<currentYear){
currentYear = maxYear
}

val months = (DateFormatSymbols(locale).shortMonths).toList()
val monthList = months.mapIndexed { index, name ->
Expand Down

0 comments on commit f4eabea

Please sign in to comment.