xo-unit: + abbrevs + tests for imperial units {in,ft,yd,mi}

This commit is contained in:
Roland Conybeare 2024-05-08 11:02:39 -04:00
commit f4c1ef5ee6
2 changed files with 17 additions and 0 deletions

View file

@ -114,9 +114,21 @@ namespace xo {
return bu_abbrev_type::from_chars("AU");
}
}
if (scalefactor.den() == 10000) {
switch(scalefactor.num()) {
case 3048:
return bu_abbrev_type::from_chars("ft");
case 3*3048:
return bu_abbrev_type::from_chars("yd");
case 5280*3048:
return bu_abbrev_type::from_chars("mi");
}
}
if (scalefactor.num() == 3048 && scalefactor.den() == 120000)
return bu_abbrev_type::from_chars("in");
return fallback_unit_abbrev(scalefactor, dimension::distance);
}