Skip to content

Commit

Permalink
Fix check current year between min/max date
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkkanB committed Oct 13, 2021
1 parent 7018f9b commit 1caecdd
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 1caecdd

Please sign in to comment.