2021-05-30 11:15:32 +00:00
|
|
|
package dev.inmo.krontab.utils
|
|
|
|
|
2023-05-25 14:53:10 +00:00
|
|
|
import korlibs.time.DateTime
|
|
|
|
import korlibs.time.Month
|
2021-05-30 11:15:32 +00:00
|
|
|
import kotlin.math.min
|
|
|
|
|
|
|
|
fun DateTime.copy(
|
|
|
|
year: Int = yearInt,
|
|
|
|
month: Int = month1,
|
|
|
|
dayOfMonth: Int = this.dayOfMonth,
|
|
|
|
hour: Int = hours,
|
|
|
|
minute: Int = minutes,
|
|
|
|
second: Int = seconds,
|
|
|
|
milliseconds: Int = this.milliseconds
|
|
|
|
) = DateTime(
|
|
|
|
year,
|
|
|
|
month,
|
|
|
|
min(Month(month).days(yearInt), dayOfMonth),
|
|
|
|
hour,
|
|
|
|
minute,
|
|
|
|
second,
|
|
|
|
milliseconds
|
|
|
|
)
|