Swiftpack.co - Package - rinat-enikeev/Humidity

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

In settings you can change locale for HumidityFormatter

HumiditySettings.setLanguage(.en)

Available two languages:

  • 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 – rinat.enikeev@gmail.com

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

Github

link
Stars: 0

Dependencies

Used By

Total: 0