Skip to content

Commit 310a280

Browse files
fix(numers): custom format grouping with negative format
1 parent 8868db7 commit 310a280

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/numbers/custom-number-format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function replacePlaceHolders(formatOptions, info) {
233233
}
234234

235235
if (hasGroup) {
236-
number = groupInteger(number, start + (negative ? 1 : 0), Math.max(end, (integerLength + start)), info.numbers.decimal, info);
236+
number = groupInteger(number, start + (negative && !hasNegativeFormat ? 1 : 0), Math.max(end, (integerLength + start)), info.numbers.decimal, info);
237237
}
238238

239239
if (end >= start) {

test/numbers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ describe('custom formatting', () => {
458458
expect(formatNumber(-0.001, "####;-(#.#)")).toEqual("-(0.0)");
459459
});
460460

461+
it("toString decimal number -1000 with negative format", () => {
462+
expect(formatNumber(-1000, "#,##0;(#,##0);-")).toEqual("(1,000)");
463+
});
464+
461465
it("applies negative format", () => {
462466
expect(formatNumber(-123, "####;-(#.00)")).toEqual("-(123.00)");
463467
});

0 commit comments

Comments
 (0)