Skip to content

Minus sign at the beginning is applied only to the first unit in composite input #104

@MoonlightCapital

Description

@MoonlightCapital

🐞 Description

Starting a composite duration with a minus sign will only treat the first block as negative.

Example:
1h30m => 5400000 CORRECT
-1h30m => -1800000 WRONG: This translates to -30 minutes
-1h30m => -5400000 CORRECT but weird

💡 Expected Behavior

The entire duration is set to negative, so for example, having -1h30m should return -5400000. This is currently achieved with -1h-30m, which is very weird.

↩️ Is This a Regression?

No.

🔬 Minimal Reproduction

Steps to reproduce the behavior:

  1. Use a composite duration that begins with a minus sign, but with no subsequent minus signs afterwards.

🔥 Error or Exception

If there's an error or an exception, please share it below:

None.

🌍 Environment

Describe your relevant environment (device, OS, browser, Node.js, packages, etc.):

Node v14.15.4
NPM 6.14.10
Windows 10 64bit
@standards/duration: 1.1.3

🖼️ Screenshots

roleduration

💬 Anything Else?

None.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions