Comments (4)
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.
@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.
@haimkastner Thank you!
from unitsnet-js.
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)
- Implement lazy load for each unit property HOT 1
- Fetch the units definition from the UnitsNet repo HOT 1
- Generate 'toString' method for each unit HOT 1
- Check ctor parameter validity HOT 1
- Expose the base value to allows high-performance access to base-value for quick calculation etc. HOT 1
- Add JSDoc from the definition XMLDoc HOT 1
- Generate 'compareTo' and 'equals' for each unit HOT 1
- Generate basic arithmetics methods for each unit HOT 1
- fix 'toString' format of prefixes units HOT 1
- Generate all prefixes units HOT 1
- Why ist "Millimeter" Missing in all Units? HOT 1
- make unit abbreviations used in .toString() accessible HOT 1
- Full support for units.net features? HOT 2
- Length.multiply() multiplicator HOT 1
- Equally use singular for unit types as in the c# project HOT 10
- Support Cross-Technologies Unit & API Specifications HOT 5
- Math in JS HOT 5
- Allow truncate fraction digits on 'toString' HOT 1
- CORS Error in OpenAPI Spec Example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unitsnet-js.