在 XPath 中舍入时间和日期时间的最简单和正确的方法是什么?
例如,如何以local:round-time-to-minutes
以下测试用例的方式定义函数:
let $t1 := xs:time( "12:58:37" )
let $t2 := local:round-time-to-minutes( $t1 )
return format-time( $t2, '[H01]:[m01]:[s01]' )
将返回"12:59:00"
。不确定在“23:59:31”的情况下哪个更好——返回“00:00:00”或引发动态错误。
还有类似的函数local:round-datetime-to-minutes
来处理日期时间?(它没有像上面这样的边缘情况)
让这些函数使用“向正无穷大的一半”规则,其中一半是 30.0 秒。