From 1876df2c2d64cd8cb5016c78281b61f072e392ed Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 17 Feb 2025 13:16:10 +0600 Subject: [PATCH] fix of year in Birthdate --- .../kotlin/dev/inmo/tgbotapi/types/Birthdate.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt index 4a0ddd7e45..b3121bb0ba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt @@ -1,6 +1,8 @@ package dev.inmo.tgbotapi.types import korlibs.time.Date +import korlibs.time.DateTime +import korlibs.time.Year import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -11,9 +13,12 @@ data class Birthdate( @SerialName(monthField) val month: Int, @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 { - Date(year, month, day) + Date(year ?: DateTime.now().year.year, month, day) } }