question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duration normalize is buggy

See original GitHub issue
Duration.fromObject({ minutes: 120 }).normalize().toObject();
// => { minutes: 120 }

Does not change anything, however when I put in hours: 0 then I get

Duration.fromObject({ hours: 0, minutes: 120 }).normalize().toObject();
// => { hours: 2, minutes: 0 };

Looking at this function from the luxon code seems to reveal the issue

function normalizeValues(matrix, vals) {
  reverseUnits.reduce(function (previous, current) {
    if (!isUndefined(vals[current])) {
      if (previous) {
        convert(matrix, vals, previous, vals, current);
      }

      return current;
    } else {
      return previous;
    }
  }, null);
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
icambroncommented, Apr 13, 2020

I’m not sure about the analogy, but yes, Luxon’s durations are just like that. It seemed too confusing for Luxon to add new keys without you telling it to (e.g. via shiftTo). You can of course add all the keys and later filter out the zeros.

0reactions
icambroncommented, Apr 16, 2020

@atruskie that’s a different problem. I think you mean example.as("years"). get is just a getter for the unit

Read more comments on GitHub >

github_iconTop Results From Across the Web

Whitespace is hard and buggy. Can we normalize it? - WICG
Whitespace is a difficult topic for many reasons, not least of which is that it's hard to see what others are talking about...
Read more >
How to doubly normalize scientific data by baseline time point ...
I would like to first take each well and normalize (as in, divide) all the parameters by the median parameters at baseline (all...
Read more >
Normalize Buggy? | Studio One Forum ... - PreSonus Forums
For the life of me, when I use the normalize function in StudioOne it brings the volume of my files DOWN every time....
Read more >
Variant Normalization - Genome Analysis Wiki
It is a property describing the nature of the length of a variant's alleles and is defined as follows: A variant is parsimonious...
Read more >
Normalize plugin buggy behavior. PT 10
Normalize plugin buggy behavior. ... slightly...if I keep hitting Render, it will incrementally go up - maybe a dB or two each time....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found