Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cuurent weather data returns null if the time in between 11 : 30 pm and 12 : 00 am #7

Open
Vaibhav-214 opened this issue May 28, 2023 · 0 comments

Comments

@Vaibhav-214
Copy link

app/src/main/java/com/plcoding/weatherapp/data/mappers/WeatherMappers.kt

in the above file in the extension function toWeatherInfo

fun WeatherDto.toWeatherInfo(): WeatherInfo { val weatherDataMap = weatherData.toWeatherDataMap() val now = LocalDateTime.now() val currentWeatherData = weatherDataMap[0]?.find { val hour = if(now.minute < 30) now.hour else now.hour + 1 it.time.hour == hour } return WeatherInfo( weatherDataPerDay = weatherDataMap, currentWeatherData = currentWeatherData ) }

here if time is between 23 : 30 and 00:00 am it will return null cause since it is > 30 minutes it will go to hour plus 1 which is 24 but there is no 24th hour, it's 0th hour. So it will return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant