Also refer FromSeconds method.
# Retrieve JSON formatted weather data
PS > $ow = Invoke-RestMethod -Uri "api.openweathermap.org/data/2.5/weather?id=1863967&units=metric&appid=xxxx" -Method Get
PS > $ow
coord : @{lon=130.42; lat=33.61}
weather : {@{id=803; main=Clouds; description=broken clouds; icon=04n}}
base : stations
main : @{temp=19.68; pressure=1004; humidity=77; temp_min=18.89; temp_max=20}
visibility : 10000
wind : @{speed=1.5; deg=270}
clouds : @{all=75}
dt : 1560090033
sys : @{type=1; id=7998; message=0.0064; country=JP; sunrise=1560024473; sunset=1560076033}
timezone : 32400
id : 1863967
name : Fukuoka-shi
cod : 200
# Let's get JST sunrise time from Unix timestamp.
PS > ((Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($ow.sys.sunrise))).AddHours(9)
2019年6月9日 5:07:53
PS > $ow = Invoke-RestMethod -Uri "api.openweathermap.org/data/2.5/weather?id=1863967&units=metric&appid=xxxx" -Method Get
PS > $ow
coord : @{lon=130.42; lat=33.61}
weather : {@{id=803; main=Clouds; description=broken clouds; icon=04n}}
base : stations
main : @{temp=19.68; pressure=1004; humidity=77; temp_min=18.89; temp_max=20}
visibility : 10000
wind : @{speed=1.5; deg=270}
clouds : @{all=75}
dt : 1560090033
sys : @{type=1; id=7998; message=0.0064; country=JP; sunrise=1560024473; sunset=1560076033}
timezone : 32400
id : 1863967
name : Fukuoka-shi
cod : 200
# Let's get JST sunrise time from Unix timestamp.
PS > ((Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($ow.sys.sunrise))).AddHours(9)
2019年6月9日 5:07:53
No comments:
Post a Comment