Skip to content

Commit

Permalink
Omit sunrises and sunsets that are at epoch second 0
Browse files Browse the repository at this point in the history
Fixes #31
  • Loading branch information
davidtakac committed Apr 19, 2024
1 parent cb98d6b commit 24dad8d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class ForecastDataDownloader(private val userAgentProvider: UserAgentProvider) {
val json = JSONObject(jsonString)

val daily = json.getJSONObject("daily")
// When a day has no sunrise or sunset, Open-Meteo returns 1970-01-01, but the app
// When a day has no sunrise or sunset, Open-Meteo returns epoch second 0, but the app
// expects an omitted timestamp. These filters drop such placeholders.
val sunrises = daily.getJSONArray("sunrise").mapToList(LocalDateTime::parse).filter { it != LocalDateTime.MIN }
val sunsets = daily.getJSONArray("sunset").mapToList(LocalDateTime::parse).filter { it != LocalDateTime.MIN }
val sunrises = daily.getJSONArray("sunrise").mapToList(LocalDateTime::parse).filter { it.year != 1970 }
val sunsets = daily.getJSONArray("sunset").mapToList(LocalDateTime::parse).filter { it.year != 1970 }

val hourly = json.getJSONObject("hourly")

Expand Down

0 comments on commit 24dad8d

Please sign in to comment.