Skip to content

viikufa/Humidity

 
 

Repository files navigation

Humidity

Calculate absolute humidity and dew point from relative humidity and temperature

Swift Version License PRs Welcome

Features

  • Absulute Humidity (g/m³)
  • Dew Point (°C, °F)

Requirements

  • iOS 10.0+
  • Xcode 10.2.1+

Installation

CocoaPods

You can use CocoaPods to install Humidity by adding it to your Podfile:

platform :ios, '10.0'
use_frameworks!
pod 'Humidity'

To get the full benefits import Humidity

import Humidity

Usage example

import Humidity

var absoluteHumidity = Humidity(value: 10.812216095573042, unit: .absolute)

// Converting
absoluteHumidity.converted(to: .relative(temperature: 24.9).value // 0.472

// DewPoint
do {
    let dewPoint = try absoluteHumidity.dewPoint(temperature: Constants.temp)
    print(dewPoint.converted(to: .fahrenheit).value) // 55.20564209577756
} catch {
    print(error.localizedDescription)
}

// HumidityFormatter
let formatter = HumidityFormatter()
formatter.unitStyle = .short

// Also you can change number formats using NumberFormatter
formatter.numberFormatter = NumberFormatter()
formatter.numberFormatter.maximumFractionDigits = 2
print(formatter.string(from: absoluteHumidity))

Localization

You can change locale for HumidityFormatter in HumiditySettings

HumiditySettings.setLanguage(.en)

Two languages are available:

  • english
  • russian

Contribute

We would love you for the contribution to Humidity, check the LICENSE file for more info.

Credits

The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use Foundation Units and Measurement at developer.apple.com

Meta

Rinat Enikeev – [email protected]

Distributed under the BSD license. See LICENSE for more information.

About

Humidity calculation library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.3%
  • Ruby 3.1%
  • Objective-C 1.6%