ant-design / ant-design/pro-components

🐛[BUG]秒格式化字段类型负数会错误显示

Open
#8,447 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

### 🐛 bug 描述

秒格式化字段类型, 无法处理负数, 即已经过去的时间, 如 `-3600` 应显示 `1小时前`.
而某些情况下, 需要展示距离某时刻的时间不紧要展示时间, 也需要区分是否是过去时, 如 `交货时间距今`.

### 📷 复现步骤

字段 `valueType="second"` 且 `value` 为负数即可复现

### 🏞 期望结果

能正常显示负数的时间格式化, 如 `xx秒前`

### 💻 复现代码

[sandbox](https://codesandbox.io/p/sandbox/headless-cookies-5v49ff)

### © 版本信息

- ProComponents 版本: [2.7.9]
- 浏览器环境: Edge
- 开发环境 [e.g. mac OS]

### 🚑 其他信息

image

Contributor guide

Open the contributing guide

Research direction

Start by running the linked CodeSandbox with a field using valueType="second" and a negative value, then trace the related formatting entry point in the ProComponents source. Done means negative seconds render as past-time text, such as -3600 displaying as 1 hour ago, while preserving the existing formatting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.