mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-17 13:33:47 +00:00
add checking of current date
This commit is contained in:
parent
65dfe8abd0
commit
34e253a12e
@ -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))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user