Closed J-N-K closed 1 month ago
Unlike DAY
or HOUR
, YEAR
and WEEK
are added to the unit system differently. Which persists the name and symbol, but does not also label them. It is not so trivial, but should be doable, e.g. by adding another style that takes name, symbol and label into consideration.
Thanks for pointing this out. There are a couple of tweaks in SimpleUnitFormat
. I added an alias, e.g. "wk" to "week", but kept the label based on https://www.btb.termiumplus.gc.ca/tcdnstyl-chap?lang=eng&lettr=chapsect1&info0=1.23,
Does this work for you, or would you expect "wk" to be the label/toString
representation?
Because other sources like convertunits.com/info/weeks list it as the symbol, but Wikipedia also prints out "week" in most cases.
In https://github.com/openhab/openhab-core/issues/3962 we found that
d
works as unit for days, buty
does not work for years. The same applied tomo
andwk
.I believe the difference is that
DAY
is defined as aTransformedUnit
and added directly byINSTANCE.units.add(unit)
whileYEAR
is added viaAbstractSystemOfUnits.Helper.addUnit(Set<Unit<?>> units, U unit, String name, String symbol)
. It seems in the latter case the symbol is not made available as alias for parsing.