-
Notifications
You must be signed in to change notification settings - Fork 2
Units of Measures
Phil Schatzmann edited this page Feb 21, 2022
·
8 revisions
I added some simple logic to handle units of measures in the NumberUnitToText class. The logic is based on 4 different array which contain the basic information:
-
unit_1 is used to handle units that can have a singular and plural: e.g. one dollar but it is two dollars
- "lb", "pound", "pounds"
- "ft", "foot", "feet"
- "in", "inch", "inches"
- "mi", "mile", "miles"
- "$", "dollar", "dollars"
- "¢", "cent", "cents"
-
unit_2: is used to assemble units from (potentially) multiple words
- "mph", "miles", "per", "hour"
- "C", "degrees", "celcius"
- "F", "degrees", "fahrenheit"
- "%", "percent"
- "lt", "liter"
- "ml", "milli", "lt"
- "gr", "gram"
- "kg", "kilo", "gr"
- "mg", "milli", "gr"
- "km", "kilo", "m"
- "m", "meter"
- "cm", "centi", "m"
- "mm", "milli", "m"
- "usd", "u.s.", "$"
-
unit3: split unit before and after the decimal point: 1.20 USD is 1 Dollar and 20 Cents
- "usd", "¢"
- "gr", "mg"
- "kg", "gr"
- "m", "mm"
- "km", "m"
- "lt", "ml"
-
decimal_info
- "usd", 2
- (default), 3
Please feel free to submit some pull request if you think some critical unit is missing!