open-meteo / sdk

Open-Meteo schema files
MIT License
18 stars 14 forks source link

How to get sunrise in Java SDK #100

Open Wemaka opened 1 month ago

Wemaka commented 1 month ago

I'm doing a flatFormat query. I have the sunrise time stored in unix format.

VariableWithValues sunrise = new VariablesSearch(daily).variable(Variable.sunrise).first(); System.out.println(sunrise.values(0)); I'm getting 0.0

This is what the response looks like in json format. "daily": { ... "sunrise": [ 1715218156, 1715304438, 1715390723 ], "sunset": [ 1715275415, 1715361928, 1715448440 ] }

How do I get a normal sunrise time in java ?

patrick-zippenfenig commented 1 month ago

Hi, sunrise and sunset are encoded as 64 bit integers in the ValuesInt64 attribute. See here: https://github.com/open-meteo/python-requests/issues/44