Formatting of negative durations contains extra minus chars
See original GitHub issueWhen toFormat("hh:mm")
is used on a negative Duration
, the resulting string can have extra minus characters.
Example:
const x = Duration.fromObject({ minutes: 60 });
const y = Duration.fromObject({ minutes: 150 });
const diff = x.minus(y);
diff.toFormat("hh:mm"); // Outputs "-1:-30" rather than the expected "-1:30"
Example is available here: https://codesandbox.io/s/43wry09vw4
Version 1.10.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Optional Format for Negative Numbers
The minus sign is not included in the output if the negativePattern contains characters not in the positivePattern. It is assumed that the...
Read more >Review guidelines for customizing a number format
A number format can have up to four sections of code, separated by semicolons. These code sections define the format for positive numbers,...
Read more >How to use the TEXT function
The first container in the formula above (bolded) lets you format positive numbers, the minus sign formats positive numbers as negative numbers.
Read more >How to display / show negative time properly in Excel?
Here is an easy and quick way for you to display the negative time normally in Excel by changing the Excel's Default Date...
Read more >Display Negative Sign Character on the Right - YouTube
This video shows how to add a negative sign character to the right of a negative number instead of having it on the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My solution:
Yeah, the formatter is a little dumb about negatives. It’s saying “(-1)😦-30)” because it doesn’t know how to pull the negative out as “-(1:30)”