GithubHelp home page GithubHelp logo

Comments (4)

haimkastner avatar haimkastner commented on June 13, 2024 1

Hi @jules-js

The "Length" object once created, is not a "Kilometer" or any other unit system, it's just "Length".
So, in order to get the abbreviation of a kilometer from the Length object you should use it like this:

First, create the object:

let length = new Length(5, LengthUnits.Kilometers);

Or

let length = Length.FromKilometers(5);

Both ways will create the Length object.

Now, if you want to get the value as Kilometer you need to specify it like this:

console.log(length.Kilometers);

And the same if you want the abbreviation of Kilometer you need to specify it like this:

console.log(length.getUnitAbbreviation(LengthUnits.Kilometers));

And if you want the Kilometer value with the abbreviation as a string specify it like this:

console.log(length.toString(LengthUnits.Kilometers));

Regarding Kilometer abbreviation, I have checked it, and it looks like there is no attribution for it.
The reason is, that all the units systems conversion, formulas, and abbreviations all generated from the UnitsNet Definition Files.

And since it's not contained unit abbreviations for prefix units (such as Kilometer, Centimeter, etc.) there is no attribution on the JS library as well.

See here how the definition of Length defined.

If you think that abbreviations for unit prefixes are valuable, please open an issue to the UnitsNet project, and once they will accept it and will add abbreviations support to unit prefixes, please re-open this issue and I will align JS library to use prefixes abbreviations as well.

Thank you!

from unitsnet-js.

haimkastner avatar haimkastner commented on June 13, 2024 1

@jules-js This issue was fixed for the Python library thanks to haimkastner/unitsnet-py#13 , and now it's also fixed for the TS package with #24

from unitsnet-js.

jules-js avatar jules-js commented on June 13, 2024 1

@haimkastner Thank you!

from unitsnet-js.

maltonic avatar maltonic commented on June 13, 2024

Hello,

i was having exact the same issue but unfortunately no fix ;(

Can someone help on this?

Thank you

from unitsnet-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.