feat: Utilize java.time in CalendarActivity
This commit is contained in:
parent
415a8e60ff
commit
1ba9a2b0ba
|
@ -12,8 +12,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.p_vacho.neat_calendar.R
|
||||
import com.p_vacho.neat_calendar.adapters.CalendarAdapter
|
||||
import com.p_vacho.neat_calendar.models.CalendarDay
|
||||
import org.threeten.bp.YearMonth
|
||||
import org.threeten.bp.format.TextStyle
|
||||
import java.time.YearMonth
|
||||
import java.time.format.TextStyle
|
||||
import java.util.Locale
|
||||
|
||||
class CalendarActivity : AppCompatActivity() {
|
||||
|
@ -63,9 +63,9 @@ class CalendarActivity : AppCompatActivity() {
|
|||
val monthYearText = "${yearMonth.month.getDisplayName(TextStyle.FULL, Locale.getDefault())} ${yearMonth.year}"
|
||||
tvMonthYear.text = monthYearText
|
||||
|
||||
// Calculate the day of the week the month starts on (Monday as first day)
|
||||
val dayOfWeek = firstDayOfMonth.dayOfWeek.value // 1 (Monday) to 7 (Sunday)
|
||||
val startOffset = (dayOfWeek - 1 + 7) % 7
|
||||
// Calculate the amount of placeholder slots until the first day in the month
|
||||
// (Our calendar starts from Monday, but not all months start on monday, so we need fillers)
|
||||
val startOffset = firstDayOfMonth.dayOfWeek.ordinal // Gives 0 (Monday) to 6 (Sunday)
|
||||
|
||||
// Generate calendar days
|
||||
val days = mutableListOf<CalendarDay>()
|
||||
|
|
Loading…
Reference in a new issue