Skip to content

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

@Vaibhav-214

Description

@Vaibhav-214

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions