Skip to content

Commit

Permalink
add more units
Browse files Browse the repository at this point in the history
  • Loading branch information
Markos-Th09 committed Nov 9, 2023
1 parent 24214b1 commit f9c00bd
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions core/src/units/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,21 +505,35 @@ const COMMON_PHYSICAL_UNITS: &[UnitTuple] = &[
];

const CGS_UNITS: &[UnitTuple] = &[
("gal", "gals", "cm/s^2", ""),
("dyne", "dynes", "g*gal", ""),
("erg", "ergs", "g*cm^2/s^2", ""),
("barye", "baryes", "g/(cm*s^2)", ""),
("gal", "gals", "cm/s^2", "accerelation"),
("dyne", "dynes", "g*gal", "force"),
("erg", "ergs", "g*cm^2/s^2", "work, energy"),
("barye", "baryes", "g/(cm*s^2)", "pressure"),
("poise", "poises", "g/(cm*s)", ""),
("stokes", "", "cm^2/s", ""),
("kayser", "kaysers", "cm^-1", ""),
];

const CGS_ABBREVATIONS: &[UnitTuple] = &[
("biot", "biots", "10 amperes", ""),
("emu", "emus", "0.001 A m^2", ""),
("franklin", "franklins", "dyn^1/2*cm", ""),
("gauss", "", "10^-4 tesla", ""),
("maxwell", "maxwells", "10^-8 weber", ""),
("phot", "phots", "10000 lux", ""),
("stilb", "stilbs", "10000 candela/m^2", ""),
// abbrevations
("gallileo", "gallileos", "gal", ""),
("dyn", "dyns", "dyne", ""),
("Ba", "", "barye", ""),
("P", "", "poise", ""),
("St", "", "", ""),
("St", "", "stokes", ""),
("K", "", "kayser", ""),
("Bi", "", "biot", ""),
("Fr", "", "franklin", ""),
("G", "", "gauss", ""),
("Lb", "", "lambert", ""),
("Mx", "", "maxwell", ""),
("Oe", "", "oersted", ""),
("ph", "", "phot", ""),
("P", "", "poise", ""),
];

const IMPERIAL_UNITS: &[UnitTuple] = &[
Expand All @@ -534,12 +548,13 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("yard", "yards", "l@3 ft", ""),
("mile", "miles", "l@5280 ft", ""),
("line", "lines", "1/12 inch", ""),
("rod", "", "5.5 yard", ""),
("pole", "", "rod", ""),
("perch", "", "rod", ""),
("furlong", "", "40 rod", ""),
("rod", "rods", "5.5 yard", ""),
("pole", "poles", "rod", ""),
("perch", "perches", "rod", ""),
("firkin", "firkins", "90 lb", ""),
("furlong", "furlongs", "40 rod", ""),
("statute_mile", "statute_miles", "mile", ""),
("league", "", "3 mile", ""),
("league", "leagues", "3 mile", ""),
("chain", "chains", "66 feet", ""),
("link", "links", "1/100 chain", ""),
("thou", "", "1/1000 inch", "thousandth of an inch"),
Expand All @@ -550,7 +565,7 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("point", "points", "l@1/72 inch", ""),
("twip", "twips", "l@1/20 point", ""),
("poppyseed", "poppyseeds", "l@line", ""),
("pica", "", "l@12 points", ""),
("pica", "picas", "l@12 points", ""),
("barleycorn", "barleycorns", "l@4 poppyseed", ""),
("finger", "fingers", "l@63 points", ""),
("stick", "sticks", "l@2 inches", ""),
Expand All @@ -561,16 +576,16 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("hand", "hands", "l@2 sticks", ""),
("shaftment", "shaftments", "l@2 palm", ""),
("cubit", "cubits", "l@2 span", ""),
("ell", "", "l@5 span", ""),
("skein", "", "l@96 ell", ""),
("spindle", "", "l@120 skein", ""),
("ell", "ells", "l@5 span", ""),
("skein", "skeins", "l@96 ell", ""),
("spindle", "spindles", "l@120 skein", ""),
("link", "links", "l@1/25 rod", ""),
("fathom", "fathoms", "l@2 yard", ""),
("shackle", "shackles", "l@15 yard", ""),
("pace", "paces", "l@5 shaftments", ""),
("step", "steps", "l@2 paces", ""),
("grade", "", "l@pace", ""),
("rope", "", "l@4 steps", ""),
("grade", "grades", "l@pace", ""),
("rope", "ropes", "l@4 steps", ""),
("ramsdens_chain", "", "l@5 rope", ""),
("roman_mile", "roman_miles", "l@50 ramsdens_chain", ""),
("gunters_chain", "gunters_chains", "l@4 rod", ""),
Expand Down Expand Up @@ -650,6 +665,9 @@ const IMPERIAL_ABBREVIATIONS: &[UnitTuple] = &[
("plf", "", "lb / foot", "pounds per linear foot"),
("lbf", "", "lb force", ""),
("psi", "", "pound force / inch^2", ""),
("fur", "furs", "furlong", ""),
("fir", "firs", "firkin", ""),
("ftn", "ftns", "forthnight", ""),
];

const NAUTICAL_UNITS: &[UnitTuple] = &[
Expand Down Expand Up @@ -722,7 +740,6 @@ pub(crate) const ALL_UNIT_DEFS: &[&[UnitTuple]] = &[
NAUTICAL_UNITS,
CURRENCIES,
CGS_UNITS,
CGS_ABBREVATIONS,
];

const SHORT_PREFIXES: &[(&str, &str)] = &[
Expand Down

0 comments on commit f9c00bd

Please sign in to comment.