mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-05 08:09:21 +00:00
fix of year in Birthdate
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
import korlibs.time.Date
|
import korlibs.time.Date
|
||||||
|
import korlibs.time.DateTime
|
||||||
|
import korlibs.time.Year
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@@ -11,9 +13,12 @@ data class Birthdate(
|
|||||||
@SerialName(monthField)
|
@SerialName(monthField)
|
||||||
val month: Int,
|
val month: Int,
|
||||||
@SerialName(yearField)
|
@SerialName(yearField)
|
||||||
val year: Int
|
val year: Int? = null
|
||||||
) {
|
) {
|
||||||
|
/**
|
||||||
|
* Represents this birthday as korlibs [Date]. Will use this year in case if [year] has not been retrieved
|
||||||
|
*/
|
||||||
val date: Date by lazy {
|
val date: Date by lazy {
|
||||||
Date(year, month, day)
|
Date(year ?: DateTime.now().year.year, month, day)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user