tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
16.05k stars 1.67k forks source link

Time Picker value use ISO 8601 #715

Open pipinet opened 3 years ago

pipinet commented 3 years ago

This function solves the problem (这个功能解决的问题)

time picker 返回的是当天的时间戳,应该是不正确的,这里面会涉及时区、与日期无关等众多因素

Expected API (期望的 API)

返回结果应该是 https://en.wikipedia.org/wiki/ISO_8601#Durations

07akioni commented 3 years ago

Time Picker 只保证调整时间戳的时间部分。

但是你说的时区问题确实存在,需要考虑一下。

Ha0ran2001 commented 3 years ago

@07akioni 生成的时间戳用mysql的FROM_UNIXTIME处理不了,我看了一下有13位,比antd生成的多了3位,这三位都是0,感觉没有必要

07akioni commented 3 years ago

@07akioni 生成的时间戳用mysql的FROM_UNIXTIME处理不了,我看了一下有13位,比antd生成的多了3位,这三位都是0,感觉没有必要

image

JS 默认的 valueof 就会出那么多位,三个零的话除以 1000 就解决了

07akioni commented 3 years ago

因为 naive 的底层是 datefns 所以回是这种状况

pipinet commented 3 years ago

可以尝试使用一下 https://moment.github.io/luxon/#/ 这里几乎是对iso-8601标准实现比较全的。