Back to Breezy Weather

Breezy Weather unit conversion and formatting library

weather-unit/README.md

6.2.08.3 KB
Original Source

Breezy Weather unit conversion and formatting library

Android library to handle:

  • Unit conversion, with syntax inspired by Kotlin duration.
  • Unit formatting in various languages, including on devices without ICU support or with missing CLDR data, with a simplified backport (no handling of plural and non-nominative rules)
  • Number formatting
  • Computing of some common weather data (apparent temperature, dew point, etc)

Remains to do:

  • Complete unit testing
  • Plus and minus operations
  • Parse from string

Summary of supported units

Android translations are provided without plural rules.

Temperature

UnitNumberFormatterMeasureFormatAndroid translations
Decidegree Celsius✅¹
Degree CelsiusAndroid >= 11Android 7 to 10Android < 7
Degree FahrenheitAndroid >= 11Android 7 to 10Android < 7
KelvinAndroid >= 11Android 7 to 10Android < 7
  • ¹ Only English, French and Esperanto translations are provided.

Supports temperature deviations conversions (such as degree days).

Supported widths for Android translations:

NarrowShortLong

Distance

UnitNumberFormatterMeasureFormatAndroid translations
MeterAndroid >= 11Android 7 to 10Android < 7
KilometerAndroid >= 11Android 7 to 10Android < 7
MileAndroid >= 11Android 7 to 10Android < 7
Nautical mileAndroid >= 11Android 7 to 10Android < 7
FootAndroid >= 11Android 7 to 10Android < 7

Supported widths for Android translations:

NarrowShortLong

Speed

UnitNumberFormatterMeasureFormatAndroid translations
Centimeter per secondAndroid >= 11Android 8 to 10Android < 8
Meter per second¹Android >= 11Android 7 to 10Android < 7
Kilometer per hour¹Android >= 11Android 7 to 10Android < 7
Mile per hour¹Android >= 11Android 7 to 10Android < 7
KnotAndroid >= 11Android 8 to 10Android < 8
Foot per secondAndroid >= 11Android 7 to 10Android < 7
Beaufort scale²Android >= 16Android < 16
  • ¹ Simplified backport where the “per unit” is combined with the duration unit below, so that for example “Mile per hour” in short width looks like “mi/h” instead of the “mph” used in some countries
  • ² Not an unit, but a scale, so during conversions, uses the starting value in meters per second of the scale level

Supported widths for Android translations:

NarrowShortLong

Precipitation

UnitNumberFormatterMeasureFormatAndroid translations
MicrometerAndroid >= 11Android 7 to 10Android < 7
MillimeterAndroid >= 11Android 7 to 10Android < 7
CentimeterAndroid >= 11Android 7 to 10Android < 7
InchAndroid >= 11Android 7 to 10Android < 7
Liter per square meterAndroid >= 11Android 8 to 10Android < 8
UnitNumberFormatterMeasureFormatAndroid translations
Micrometer per hourAndroid >= 11Android 8 to 10Android < 8
Millimeter per hourAndroid >= 11Android 8 to 10Android < 8
Centimeter per hourAndroid >= 11Android 8 to 10Android < 8
Inch per hourAndroid >= 11Android 8 to 10Android < 8
Liter per square meter per hour

Supported widths for Android translations:

NarrowShortLong

Pressure

UnitNumberFormatterMeasureFormatAndroid translations
Pascal
HectopascalAndroid >= 11Android 7 to 10Android < 7
Kilopascal
AtmosphereAndroid >= 11Android < 11
Millimeter of mercuryAndroid >= 11Android 7 to 10Android < 7
Inch of mercuryAndroid >= 11Android 7 to 10Android < 7

Supported widths for Android translations:

NarrowShortLong

Air pollutant concentration

UnitNumberFormatterMeasureFormatAndroid translations
Microgram per cubic meterAndroid >= 11Android 8 to 10Android < 8
Milligram per cubic meterAndroid >= 11Android 8 to 10Android < 8

Supported widths for Android translations:

NarrowShortLong

Pollen concentration

UnitNumberFormatterMeasureFormatAndroid translations
Per cubic meter

Supported widths for Android translations:

NarrowShortLong

Duration

UnitNumberFormatter¹MeasureFormatAndroid translations
NanosecondAndroid >= 11Android 7 to 10Android < 7²
MicrosecondAndroid >= 11Android 7 to 10Android < 7²
MillisecondAndroid >= 11Android 7 to 10Android < 7²
SecondAndroid >= 11Android 7 to 10Android < 7
MinuteAndroid >= 11Android 7 to 10Android < 7
HourAndroid >= 11Android 7 to 10Android < 7
DayAndroid >= 11Android 7 to 10Android < 7²
  • ¹ NumberFormatter supports only single duration, and will not be used when needing a formatting like 1 hour and 30 minutes.
  • ² Only English translations are provided.

Supported widths for Android translations:

NarrowShortLong

Ratio

UnitNumberFormatter¹NumberFormatAndroid translations
PermilleAndroid >= 11Android < 11¹
PercentAndroid >= 11Android < 11
FractionAndroid >= 11Android < 11N/A
  • ¹ Only English translations are provided.

Supported widths for NumberFormat and Android translations:

NarrowShortLong

License

  • This library: GNU Lesser General Public License v3.0
  • The Unicode CLDR data: Copyright © 1991-Present Unicode, Inc. Unicode License v3