Private/Convert-Current.ps1
filter Convert-Current([TimeSpan]$TimeZoneOffset = [TimeSpan]::Zero, [string]$TemperatureUnit) { $DateTimeUtc = Get-Date -UnixTimeSeconds $_.dt -AsUTC $SunriseUtc = Get-Date -UnixTimeSeconds $_.sunrise -AsUTC $SunsetUtc = Get-Date -UnixTimeSeconds $_.sunset -AsUTC [PSCustomObject]@{ PSTypeName = 'UncommonSense.Weather.Current' DateTimeUtc = $DateTimeUtc DateTime = $DateTimeUtc.Add($TimeZoneOffset) SunriseUtc = $SunriseUtc Sunrise = $SunriseUtc.Add($TimeZoneOffset) SunsetUtc = $SunsetUtc Sunset = $SunsetUtc.Add($TimeZoneOffset) TemperatureUnit = $TemperatureUnit Temperature = $_.temp FeelsLike = $_.feels_like Pressure = $_.pressure Humidity = $_.humidity DewPoint = $_.dew_point CloudinessPercent = $_.clouds UVIndex = $_.uvi Visibility = $_.visibility WindSpeed = $_.wind_speed WindGust = $_.wind_gust WindDirection = $_.wind_deg RainVolumeLastHour = $_.rain.'1h' SnowVolumeLastHour = $_.snow.'1h' Weather = $_.weather | Convert-Weather } } |