add checking of current date

This commit is contained in:
InsanusMokrassar 2022-12-13 12:39:32 +06:00
parent 65dfe8abd0
commit 34e253a12e

View File

@ -101,16 +101,36 @@ object ButtonsBuilder {
} }
} }
fun DateTimeTz.dateEq(other: DateTimeTz) = yearInt == other.yearInt && month0 == other.month0 && dayOfMonth == other.dayOfMonth
buildStandardDataCallbackQuery( buildStandardDataCallbackQuery(
changeHoursDataPrefix, changeHoursDataPrefix,
(0 until 24).toList().let { { _ -> it } } // TODO::Add filter of hours which are in the past {
val now = DateTime.now().local
val local = it.local
if (now.dateEq(local)) {
now.hours .. 23
} else {
0 .. 23
}
}
) { newValue, oldDateTime -> ) { newValue, oldDateTime ->
oldDateTime.copyDayOfMonth(hours = newValue) oldDateTime.copyDayOfMonth(hours = newValue)
} }
buildStandardDataCallbackQuery( buildStandardDataCallbackQuery(
changeMinutesDataPrefix, changeMinutesDataPrefix,
(0 until 60).toList().let { { _ -> it } } // TODO::Add filter of hours which are in the past {
val now = DateTime.now().local
val local = it.local
if (now.dateEq(local)) {
now.minutes .. 60
} else {
0 .. 60
}
}
) { newValue, oldDateTime -> ) { newValue, oldDateTime ->
oldDateTime.copyDayOfMonth(minutes = newValue) oldDateTime.copyDayOfMonth(minutes = newValue)
} }
@ -118,17 +138,31 @@ object ButtonsBuilder {
buildStandardDataCallbackQuery( buildStandardDataCallbackQuery(
changeDayDataPrefix, changeDayDataPrefix,
{ {
val days = it.month.days(it.year) val now = DateTime.now().local
val local = it.local
1 .. days if (now.dateEq(local)) {
} // TODO::Add filter of hours which are in the past now.dayOfMonth .. it.month.days(it.year)
} else {
1 .. it.month.days(it.year)
}
}
) { newValue, oldDateTime -> ) { newValue, oldDateTime ->
oldDateTime.copyDayOfMonth(dayOfMonth = newValue) oldDateTime.copyDayOfMonth(dayOfMonth = newValue)
} }
buildStandardDataCallbackQuery( buildStandardDataCallbackQuery(
changeMonthDataPrefix, changeMonthDataPrefix,
(1 .. 12).toList().let { { _ -> it } } // TODO::Add filter of hours which are in the past {
val now = DateTime.now().local
val local = it.local
if (now.year == local.year) {
now.month1 .. 12
} else {
1 .. 12
}
}
) { newValue, oldDateTime -> ) { newValue, oldDateTime ->
oldDateTime.copyDayOfMonth(month = Month(newValue)) oldDateTime.copyDayOfMonth(month = Month(newValue))
} }