gpt4 book ai didi

scala - 这是liftweb TimeHelpers : 60. 分钟不等于1.hour 的错误吗

转载 作者:行者123 更新时间:2023-12-01 02:40:55 33 4
gpt4 key购买 nike

scala> import net.liftweb.util.TimeHelpers._

import net.liftweb.util.TimeHelpers._

scala> 60.minutes == 1.hour

res14: Boolean = false

scala>

最佳答案

据大卫波拉克(谁应该知道),这是由于乔达时间。见 Is It a bug of liftweb TimeHelpers: 60.minutes not equals 1.hour .

解决方案是转换为 Duration,然后比较两个值。来自 Period.java :

The definition of a period also affects the equals method. A period of 1 day is not equal to a period of 24 hours, nor 1 hour equal to 60 minutes. This is because periods represent an abstracted definition of a time period (eg. a day may not actually be 24 hours, it might be 23 or 25 at daylight savings boundary). To compare the actual duration of two periods, convert both to durations using toDuration, an operation that emphasises that the result may differ according to the date you choose.



这个解决方案是由andreak提供的,在上面指向google group thread的链接上,复制到这里以便其他人可以在这里找到它。

关于scala - 这是liftweb TimeHelpers : 60. 分钟不等于1.hour 的错误吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8418858/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com