Skip to content

Commit

Permalink
feat(form): the second field supports negative numbers (#8449)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsl-gr authored Jun 6, 2024
1 parent 0ce8bcd commit 7026085
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/field/src/components/Second/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export type FieldDigitProps = {
*/
export function formatSecond(result: number) {
let formatText = '';
let past = false;
if (result < 0) {
result = -result;
past = true;
}
const d = Math.floor(result / (3600 * 24));
const h = Math.floor((result / 3600) % 24);
const m = Math.floor((result / 60) % 60);
Expand All @@ -33,6 +38,9 @@ export function formatSecond(result: number) {
if (d > 0) {
formatText = `${d}${formatText}`;
}
if (past) {
formatText += '前';
}
return formatText;
}

Expand Down

0 comments on commit 7026085

Please sign in to comment.