Incorrect date comparison
Closed this issue · 1 comments
BorzdeG commented
import khronos.Dates.today
import khronos.day
fun main() {
val d = 0.day.ago
val n = today
println(d)
println(n)
println(d > n)
println(0.day.ago > today)
}
Mon Jan 06 14:29:48 MSK 2020
Mon Jan 06 14:29:48 MSK 2020
false
true // incorrect - expect `false`
urgentx commented
This is intended behaviour. In the last line, you are creating a new Date instance with the current time with millisecond precision. This will correctly be evaluated by the java.util.Date.compareTo()
function as larger than the today
variable you created earlier.