todayTimeSpan() does not account for time zone, but OpenWeatherMap API does
alan-rodriguez opened this issue · comments
This becomes a problem when the date of your time zone differs from the date of GMT time.
ForecastByZipCodeRequest
obtains a weekly forecast starting with today in your current time zone.ForecastDb.requestForecastByZipCode(zipCode, todayTimeSpan())
filters out the first row ofDayForecastTable
because its columnDATE
precedestodayTimeSpan()
.ForecastProvider.requestByZipCode(zipCode, days)
never returns a non-null value.
I am in America/New York (EDT GMT -04:00 DST) time zone. Here is a real example when I run the app:
System.currentTimeMillis()
is 1464056054644, or May 23, 2016 at 10:14:14 PM EDT GMT-4:00 DSTtodayTimeSpan()
is 1464048000000, or May 23, 2016 at 8:00:00 PM EDT GMT-4:00 DST- Date values for returned by OpenWeatherMap for seven-day forecast are: {1464001200000, 1464087600000, 1464174000000, 1464260400000, 1464346800000, 1464433200000, 1464519600000}
- Database only returns {1464087600000, 1464174000000, 1464260400000, 1464346800000, 1464433200000, 1464519600000}
The end result of this issue is org.jetbrains.anko.async
catches the NoSuchElementException
thrown by CollectionsExtensions.firstResult
, so the application does not crash, but it never loads any data into MainActivity.forecastList
. This is probably what was happening in #5.
I see... thanks! I'll try to find some time to fix it ASAP. If you think you can find a good solution for it, I'll also be glad to review a PR.
@antoniolg I'll submit a PR sometime this week