2024-11-29 17:52:58 +09:00

39 lines
962 B
Kotlin

package com.example.calrendarview.model
import android.os.Build
import androidx.annotation.RequiresApi
import java.time.LocalDate
@RequiresApi(Build.VERSION_CODES.O)
class CalendarBean: DayInfo {
constructor(date: LocalDate) {
this.day = date
}
constructor(y: Int, m: Int, d: Int) {
this.day = LocalDate.of(y, m , d)
}
private val today: LocalDate = LocalDate.now()
private val day: LocalDate
override fun getNumOfDay(): Int = this.day.dayOfMonth
override fun getMonth(): Int = this.day.monthValue
override fun getYear(): Int = this.day.year
override fun getDayOfWeek(): String = this.day.dayOfWeek.toString()
override fun isToday(): Boolean = day.isEqual(today)
fun getNumOfToday(): Int = this.today.dayOfMonth
fun getMonthOfToday(): Int = this.today.monthValue
fun getYearOfToday(): Int = this.today.year
fun getTodayOfWeek(): String = this.today.dayOfWeek.toString()
}