Skip to content

Commit 5d9f971

Browse files
committed
feat(date): 添加 isMillisecondTimestamp 判断
1 parent b0304f8 commit 5d9f971

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/date/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,16 @@ export function isMillisecondTimestamp(value: unknown): boolean {
8686
* ```
8787
*/
8888
export function convertToDayjsParam(value: DateLike) {
89-
// 如果是数字,且是10位数字,则可能是秒级时间戳,需要转为毫秒
89+
// 如果已经是毫秒级时间戳,直接返回
90+
if (isMillisecondTimestamp(value)) {
91+
return value
92+
}
93+
94+
// 如果是数字且是10位数字,则可能是秒级时间戳,需要转为毫秒
9095
if (isNumber(value) && String(value).length === 10) {
9196
return value * 1000
9297
}
98+
9399
return value
94100
}
95101

0 commit comments

Comments
 (0)